This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC26X2R1: GATT_bm_alloc() returns value

Part Number: LAUNCHXL-CC26X2R1

Hi,

I am working on the Simple Peripheral application and have modified the project.

Right now I am sending the notification with help of GATT_Notification. Before sending out the notification we are using GATT_bm_alloc() to allocate the desired memory. I have read the description of GATT_bm_alloc() from developer guide(as shown below or http://software-dl.ti.com/simplelink/esd/simplelink_cc13x0_sdk/2.20.00.38/exports/docs/blestack/blestack-api/group__GATT__BM__API.html#gaaf21b84a128832b1f4b5ef0638580d9b ). In return value, what does failure/error indicate i.e. Is it possible that this function can return pointer to heap allocation when "pSizeAlloc" is not equal to requested "size"? Or Is it going to return NULL in that case?
Can you clarify on what condition "pointer to heap allocation" will be return?
 

Regards,
Shiv

  • Hi Shiv,

    I have looked through the stack and believe I understand your question.

    pSizeAlloc is simply an empty pointer that you pass in, and GATT_bm_alloc will store the number of bytes allocated in it after the allocation is complete. This parameter is not used to determine the failure or success of this function, it is only used to notify the caller how much heap that have allocated. If you do not need this information, you can simply pass in NULL (which the stack also does in most places).

    This function will only return null if it unable to allocate the (size + headerSize) number of bytes from the heap (headerSize being based on the opcode that you passed in). This heap allocation is managed at the OSAL layer. 

    I believe this answers your question, but if misunderstood what you wanted to know or if you have any other questions, please let me know.

    Best Regards,
    Alec