Im working in a memory restricted environment and need to create strings dynamically, but still have them not take up heap memory. So does this make sense:
static char staticStringBuffer[10240];
static size_t staticStringWatermark = 0;
void createString( const char * something, const char * somethingElse ) {
char buf[1024];
strcat(buf, "test");
strcat(buf, something);
strcat(buf, somethingElse);
strcat(&staticStringBuffer[staticStringWatermark], buf);
staticStringWatermark += strlen(buf+1);
}
This probably dosent compile, but is what I am attempting sane – sacrificing static memory for heap memory?
Thank-you ^_^
That of course depends on what your particular environment does when it loads your program; where is the program’s static data put? On many operating systems, the program is loaded into heap memory and run from there, so your static data will still end up on the heap.