Memory is memory, and it does not matter how it was allocated.
As long as you map new to delete , new[] to delete[] and malloc / calloc using free (also realloc ), you're fine.
If you think about it, even C allocates memory in different places, and it works fine - if the library expects an int , you can allocate it either on the stack or on the heap (or in some global storage):
int a; int* b = malloc(sizeof(int)); static int c; some_func(&a); some_func(b); some_func(&c);
source share