Uses scalable static storage for memory.
#include <stdio.h>
#include <stdlib.h>
// C example using large static arrays.
// Meant to develop memory storage that is determined for scalable purposes.
// Size of static buffer
#define ACT_SIZE 1000000
//buffer
static unsigned char ACTIVE_BUF[ACT_SIZE];
static const unsigned char* ACTIVE_START = ACTIVE_BUF;
static const unsigned char* ACTIVE_END = ACTIVE_BUF + ACT_SIZE;
static unsigned char* ACTIVE_PTR = ACTIVE_BUF;
// Fast functions to move the internal pointer.
static inline void
Active_inc(void)
{
ACTIVE_PTR++;
}
static inline void
Active_dec(void)
{
ACTIVE_PTR--;
}
// Writes any pointer into the active buffer.
void Active_write(void* item, size_t size)
{
unsigned char* reader = item;
if(size > (ACTIVE_END - ACTIVE_PTR)) return;
while(item--)
{
*ACTIVE_PTR++ = *reader++;
}
}
int main(void)
{
printf("The active pointer is at %p\n", ACTIVE_PTR);
Active_inc();
printf("The active pointer is at %p\n", ACTIVE_PTR);
return 0;
}