im getting a "debug assertion error" when this code compiles, with the expression _CrtIsValidHeapPointer(block), can anyone explain why this has happened, and how to resolve
typedef struct _POOL
{
int size;
void* memory;
} Pool;
Pool * allocatePool(int n)
{
int *p = (int*)malloc(sizeof(int) * n);
Pool pool = { sizeof(*p), *p };
return &pool;
}
void freePool(Pool* pool)
{
free(pool);
}