0
0

So I’m implementing geometry support, but I’m confused now. Looking at the API it seems that we have:
System::loadGeometry(void * data, int datasize, FMOD::Geometry ** geometry)
and
Geometry::save(void * data, int * datasize)

Now, shouldn’t the save function take a double-void-pointer? (ie void**) I mean, presumably you’re allocating data in there, and the datasize value will be filled with the size of the data, but then I’d need to pass in the address of my void* so that you can allocate the memory (or at least point it at your own internal representation, or however it works), and I can get the value back.

Am I missing something, or is this really a problem?

Thanks!

  • Guy
  • You must to post comments
0
0

Thanks!

Hm. I’m not sure about whether to change that function, though.

On the one hand, the convenience of just passing in the void** is nice, but it may not be clear that there is memory being allocated, and that may cause memory leaks if it’s not cleaned up properly. (In this case, it would need to be well-documented that memory is allocated, and needs to be freed…which actually becomes an issue if you use the FMOD::Memory_Initialize() routines, the memory would not be allocated properly.)

Then I take it back. I would say that the desired behavior would be to separate that out into two functions, one to get the required size, and another to write the data to an allocated buffer. Maybe don’t even pass the size in as a parameter to the second function, so it would look something like:
Geometry::getBinarySize(int * size)
Geometry::save(void *)

Just my thoughts. Thank you!

  • Guy
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.