* Add a line of text to the window. The first line in the circular list * becomes the last. So all we have to do is copy the new line over the * old one. If the line buffer is too small, then allocate a new, larger * one. */
| 389 | * one. |
| 390 | */ |
| 391 | static void |
| 392 | add_line(struct mesg_info_t *mesg_info, const char *s) |
| 393 | { |
| 394 | struct line_element *curr = mesg_info->head; |
| 395 | int new_line_length = strlen(s); |
| 396 | |
| 397 | if (new_line_length + 1 > curr->buf_length) { |
| 398 | if (curr->line) |
| 399 | free(curr->line); /* free old line */ |
| 400 | |
| 401 | curr->buf_length = new_line_length + 1; |
| 402 | curr->line = (char *) alloc((unsigned) curr->buf_length); |
| 403 | } |
| 404 | |
| 405 | Strcpy(curr->line, s); /* copy info */ |
| 406 | curr->str_length = new_line_length; /* save string length */ |
| 407 | |
| 408 | mesg_info->head = mesg_info->head->next; /* move head to next line */ |
| 409 | mesg_info->dirty = True; /* we have undrawn lines */ |
| 410 | } |
| 411 | |
| 412 | /* |
| 413 | * Save a position in the text buffer so we can draw a line to separate |
no test coverage detected