This documents an old version of bs::framework. Click here to see the latest release.
Memory allocation

When allocating memory in bs::f it is prefered (but not required) to use bs::f allocator functions instead of the standard new / delete operators or malloc / free.

This ensures the bs::f can keep track of all allocated memory, which ensures better debugging and profiling, as well as ensuring that internal memory allocation method can be changed in the future.

// Helper structure
struct MyStruct
MyStruct() {}
MyStruct(int a, bool b)
:a(a), b(b)
{ }
int a;
bool b;
// Allocating memory the normal way
MyStruct* ptr = new MyStruct(123, false);
MyStruct** ptrArray = new MyStruct[5];
void* rawMem = malloc(12);
delete ptr;
delete[] ptrArray;
// Allocating memory the bs::f way
MyStruct* bsPtr = bs_new<MyStruct>(123, false);
MyStruct** bsPtrArray = bs_newN<MyStruct>(5);
void* bsRawMem = bs_alloc(12);
bs_deleteN(bsPtrArray, 5);