free - finding the size of the pointer to free. #622
Unanswered
wmjenkinson
asked this question in
Q&A
Replies: 3 comments 1 reply
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Not sure if I follow you, what I am trying to achieve is when free a pointer that say points to 10 bytes, that when I free it, it will take 10 bytes from the global value, "mem_usage". `void *malloc (size_t nSize) }` `void free (void *pBlock) }` |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Yes. Another problem can be, that these functions can be called at IRQ_LEVEL
and maybe from multiple cores. You should protect the variable mem_usage with
a spin lock, or use atomic access functions in <circle/atomic.h>. If you still
have problems, I need more info, what happens.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following but it does not seem to work. I want to decrement the size of memory pointed to be pBlock.
void free (void *pBlock)
{
THeapBlockHeader *pBlockHeader = (THeapBlockHeader *) ((uintptr) pBlock - sizeof (THeapBlockHeader));
}
Beta Was this translation helpful? Give feedback.
All reactions