The first problem is that the OP hasn't specified the interface - other than it's using c-style strings.
For a function, is:
1) Modify the original string. Need the max size to which the string can be extended:
void tripleSpace(char* str, size_t maxSpace);
2) Create a new string in a given memory with a specified max size, keeping the original:
void tripleSpace(char* dest, const char* src, size_t destMaxSpace);
3) Create a new string in new allocated memory and return a pointer to new memory, keeping the original and caller has to free when finished with it:
char* tripleSpace(const char* str);
????????????