I'm attempting to differentiate literal strings from allocated strings so I don't accidentally try to free() literal strings, which would cause a segfault.
The reason I might try to free() literal strings involve a strcat() wrapper that can be embedded thusly:
strcatex("My name ", strcatex("is ", strMyName));
void* mallocex(int intBytes)
newPtr = malloc(intBytes);
if(newPtr == 0)
else if(newPtr > maxPointer)
maxPointer = newPtr;
int SafeFree(void **ptr)
if((unsigned long) ptr > (unsigned long) maxPointer)
newString = (char*) mallocex(12);
strcpy(newString, "Example one");
There is no such guarantee don't rely on it.
A string literal is allocated memory somewhere in the read-only implementation defined region there is no way to know what that will be in a portable manner and hence you should not make any assumptions about it.