festvox / flite

A small fast portable speech synthesis system
Other
861 stars 186 forks source link

Add method to override memory operations for an application #18

Closed Elbeeo closed 4 years ago

Elbeeo commented 5 years ago

For game consoles, and often game engines in general, we don't allow use of global malloc/free. This allows us to very carefully manage our memory usage for both efficiency, in terms of performance and memory layout, and stability.

This change just adds a define that, if defined, removes the definition of the cst_ allocation functions. This forces the user to define their own versions.

I also looked at quite simply removing the call to malloc and replacing that with a define as follows:

#ifndef CST_USER_MALLOC #define CST_LLMALLOC(x) malloc(x) #endif

I went against that since it requires considerably more code changes and the maintenance would be more difficult when looking at the number of platforms flite supports.

With the higher level change I made, we can simply override it for the platforms we care about and leave it as is for others.

Ideally, a compromise would be to create a sort of cst_allocator, but that gets more complicated and I feel would bloat the flite system.