C API malloc hassle

Bumbled into this because a library I'm pulling in uses calloc instead of malloc, and setup.c doesn't override that one. That didn't work well on device, or in the simulator with the 16MB malloc pool enabled. Since the library already has its own alias to calloc, I just redefined that alias to hit my own "pdcalloc" instead of calloc, where pdcalloc just calls malloc (which in turn calls pdrealloc) and memset. This fixes everything but it's not really the most beautiful approach to mess with a library that I don't own and I might want to take updates to someday.

void * pdcalloc(size_t count, size_t size) {
	void * retval = malloc(count * size);
	memset(retval, 0, size * count);
	return retval;
}
  1. Would it be worthwhile for setup.c to handle calloc as well?
  2. Is there a more elegant way to do this in my project, outside the library? Just directly redefining calloc in my glue code that gets built before Chipmunk works in the simulator, but not on device:
void* calloc(size_t count, size_t size) {return pdcalloc(count, size);}

Presumably that's because there's a _calloc_r that's what I have to redefine if TARGET_PLAYDATE (along the lines of _malloc_r et al) but that stuff has extra entanglements that look a bit above my paygrade. I've lost what little C/C++ fluency I had years ago, and am really in a banging-rocks-together mode.