Since malloc simply returns a block of memory, you can add additional information to the block telling how many elements are in the array, this is one way if you cannot add an argument that tells the size of the array
eg.
char* ptr = malloc( sizeof(double) * 10 + sizeof(char) );
*ptr++ = 10;
return (double*)ptr;
, PHP, , .