C hack: replace printf to collect output and return complete string by using a line buffer
Bug

Your code in tprntNewLine() doesn't guarantee that tReturnString is large enough to hold the output string.

Suppose at entry to the function, these are the values of your variables:

sizeOfReturnBuffer = 10;
curPosOutBuffer    = 0;


And then you get an outLine whose length is 80.  After this piece of code:


if (remainingLenOutBuffer &lt; 0) {
    newSize = sizeOfReturnBuffer + sizeof(char)*incrSizeOfReturnBuffer;
    if ((newOutBuffer = realloc(tReturnString, newSize)) != 0) {
        tReturnString = newOutBuffer;
        sizeOfReturnBuffer = newSize;
    } else {
        lenOutLine += remainingLenOutBuffer; //just write part that is still available
        remainingLenOutBuffer = 0;
    }
}



You will increase the size of your output buffer from 10 to 15 (because you only add incrSizeOfReturnBuffer to the current size).

After that, you will then try to copy 80 bytes from outLine into your 15 byte buffer:


snprintf(&amp;tReturnString[curPosOutBuffer], lenOutLine+1, "%s\n", outLineBuffer);



You need to change your reallocation amount to ensure that it is at least enough to hold the length of the line you are trying to append.  For example:

if (remainingLenOutBuffer &lt; 0) {
    int neededSize = -remainingLenOutBuffer;

    if (neededSize &lt; incrSizeOfReturnBuffer)
        neededSize = incrSizeOfReturnBuffer;
    newSize = sizeOfReturnBuffer + neededSize;
    // ...




Style issues


Typically, constants that are #defined are in capital letters and in snake_case. So I would change:

#define initialSizeOfReturnBuffer 10


to

#define INITIAL_SIZE_OF_RETURN_BUFFER 10

There's no need to use sizeof(char).  It's always 1.