Search code examples
blackberry-10battery

Battery info from the Blackberry 10 SDK


I tried this code:

battery_info_t **pointer=NULL;
battery_get_info(pointer);
return battery_info_get_time_to_empty(*pointer); // needs simple pointer (*pointer)

My question is: how can i convert **pointer to *pointer


Solution

  • In this usage the battery_info_... function calls take a pointer to a battery_info_t type, so you would declare pointer as that and use it as the argument to those calls. To set pointer to the correct value you pass a pointer to it to battery_get_info(). You must also free the memory allocated to pointer when you are done:

    battery_info_t    *pointer = NULL;
    battery_get_info(&pointer);
    int t = battery_info_get_time_to_empty(pointer);
    battery_free_info(&pointer);
    return t;