memory_stub.c no longer needed?


#1

I just upgraded to Developer Studio v1.2.0, and I noticed that the memory_stub.c file I have in my project (to declare malloc/free using the adl_memGet and release functions) was causing compilation problems. I commented out the file contents, and it successfully compiled. The binary seems stable, so I am guessing that memory_stub.c is no longer needed. Can someone confirm this?

Cory


#2

It does not depend on the IDE but on the OS version you compile against. 6.34 includes malloc, free and calloc. (Calloc does not seem to check for NULL before memset though, but have not tested it). realloc and the reentrant versions seems not to be included, so you might still want to add those…

see [url]https://forum.sierrawireless.com/t/why-so-many-toolchains/4746/8]


It is actually a post of yours which rang some alarm bells,
[url]https://forum.sierrawireless.com/t/c-new-delete-vs-adl-memget/4613/2]

void *calloc(size_t n, size_t s)
{
   void *p = malloc(n*s);
  // NULL???
   memset(p, 0, n*s);
   return p;
}

I would not trust memset to handle NULL pointers correctly, since afaik it is a highly optimized version to set a block (and therefore most likely does not check for valid arguments)