5 /** If buffer is too small to hold entire string, it is incremented by this value */
9 * Program reads entire lines of text from the standard input and returns them
10 * on the standard output without changing anything.
13 /** Currently fetched from stdin character */
16 /** Buffer used to store line of characters */
19 /** Current buffer length*/
20 int buffer_length = 0;
22 /* Index of the current character */
25 /** Temporary buffer used as a proxy between
26 * checking memory allocation and copying data to real buffer
34 * Check if current index is bigger than current buffer size.
35 * If so increment buffer size. On error release memory, and set
38 if (i >= buffer_length) {
40 buffer_length += BUFFER_STEP;
41 tmp = (char*) realloc(buffer, buffer_length);
43 fprintf(stderr, "[%s] Memory allocation problem on read!\n", "process1");
51 * If there were no errors parse data.
54 /* If newline has been found
55 * return entire string and release the memory
58 fprintf(stdout, "%s\n", buffer);
68 * Normal character, add it to the buffer
76 printf("c: %c/%d, i: %d, bl: %d\n", c, c, i, buffer_length);