Makes sure there is room in the token buffer.
| 451 | |
| 452 | // Makes sure there is room in the token buffer. |
| 453 | static void token_buf_room(void) |
| 454 | { |
| 455 | if (token_len == token_alloc) { // all space used up |
| 456 | if (!token_alloc) { // first time allocation |
| 457 | token_alloc = 65536; |
| 458 | if (!(token_buf = malloc(token_alloc))) { |
| 459 | fprintf(stderr, "(F): Allocation of token buffer failed.\n"); |
| 460 | exit(4); |
| 461 | } |
| 462 | token_buf[0] = '\0'; // for safety |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | token_alloc <<= 1; |
| 467 | if (!(token_buf = realloc(token_buf, token_alloc))) { |
| 468 | fprintf(stderr, "(F): Reallocation of token buffer failed.\n"); |
| 469 | exit(4); |
| 470 | } |
| 471 | //fprintf(stderr, "Realloc-ed token buf.\n"); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | // Appends a character to the token buffer, always making sure there is room. |
| 476 | static void token_buf_push(int cc) |
no outgoing calls
no test coverage detected