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.

RTOS/CC2650: HeapBuf align argument

Part Number: CC2650


Tool/software: TI-RTOS

Hello,

Looking through the documentation for HeapBuf, I see that the call below allocates a certain size of memory (Blocks size?) based on an align property, however, in the documentation it also states that "All alignment is handled in the create, therefore the align argument in alloc is ignored". Does this mean that any value I put into the third argument is irrelevant? Also, if I decide to set the size of the HeapBuf_Params.blockSize before memory allocation, why should we be required to pass argument #2 of SizeT size? Thank you!

Ptr HeapBuf_alloc(HeapBuf_Handle handle, SizeT size, SizeT align, Error_Block *eb); 

  • I'm assuming this is a dup of e2e.ti.com/.../594916

    Todd
  • Hello,

    No it is not the same question. The link you are referring to is a question about initializing a HeapBuf, and this thread is about a function call to allocating memory within a HeapBuf that has slightly contradicting (at-least to my understanding) function arguments.

  • Sorry. I read it too fast.

    The alignment in the HeapBuf_alloc call is not used except to do an assert check (to make sure you are not requesting something that cannot be honored).

    All the heap modules (e.g. HeapMem, HeapBuf, etc.) must adhere to a common interface called IHeap. This allows the Memory module to be the front end to all memory allocation. Therefore even though HeapBuf does not really need the align parameter on the alloc (or the size on the free), they must be there.

    We recommend people not to call the Heap modules alloc and free calls directly. We recommend they use Memory_alloc and Memory_free instead. The small layer does some common error handling and alignment management.

    Todd