/** Add a feature to a (mutable) LV2 feature array. */
static inline void
suil_add_feature(LV2_Feature*** features,
                 unsigned*      n,
                 const char*    uri,
                 void*          data)
	for (unsigned i = 0; i < *n && (*features)[i]; ++i) {
		if (!strcmp((*features)[i]->URI, uri)) {
			(*features)[i]->data = data;

	*features = (LV2_Feature**)realloc(*features,
	                                   sizeof(LV2_Feature*) * (*n + 1));

	// Initialize the new feature here (and increment the array size)
suil_add_feature is used to add features to an existing array of pointers to type LV2_Feature. Initially, the array gets searched to see if the feature already exists. If it doesn't, the existing array gets increased by one element which then gets initialized to the new LV2_Feature value. Resizing is done using realloc()

I'm having a problem when I build a Debug version. The first 5 times I call suil_add_feature() realloc() ends up calling _realloc_dbg() (in dbgheap.c) and everything works fine. But on the sixth call, realloc() calls _realloc_base() (in realloc.c) which brings everything crashing down. I assume that _realloc_base() is intended for the normal (non-debug heap). So this particular app is somehow linking to both the debug and non-debug runtime modules.

If I was building using the VS IDE I could probably figure this out - but although my compiler is MSVC, my build environment is waf, which I'm a bit unfamiliar with. I'm guessing I need to add some lines to my waf script to let it know that it shuld ignore the non-debug runtime libraries when building a Debug version.

Can I achieve this by adding /NODEFAULTLIB to the linker options or is it more complicated than that?