The example below demonstrates how the alternative C library can be used to dynamically allocate memory blocks.
#include <stdio.h>
#include "ST_API.h"
#define TEST_COUNT 8
int main(void)
{
int i;
PVOID Buffers[TEST_COUNT];
/* Initialization */
arInit();
stInit();
/* Allocate 8 buffers, 128 bytes each */
for(i = 0; i < TEST_COUNT; i++)
{
Buffers[i] = stMemAlloc(128);
printf("Iteration %i: stMemAlloc(128) = %p\n", i, Buffers[i]);
}
/* Release allocated memory buffers */
for(i = 0; i < TEST_COUNT; i++)
stMemFree(Buffers[i]);
/* Deinitialization */
arDeinit();
return 0;
}