static void text_chunk_line_free(TEXT_BUFFER_REC *buffer, LINE_REC *line) { TEXT_CHUNK_REC *chunk; const unsigned char *text; unsigned char cmd, *tmp = NULL; for (text = line->text;; text++) { if (*text != '\0') continue; text++; cmd = *text; if (cmd == LINE_CMD_CONTINUE || cmd == LINE_CMD_EOL) { if (cmd == LINE_CMD_CONTINUE) memcpy(&tmp, text+1, sizeof(char *)); /* free the previous block */ chunk = text_chunk_find(buffer, text); if (--chunk->refcount == 0) { if (buffer->cur_text == chunk) chunk->pos = 0; else text_chunk_destroy(buffer, chunk); } if (cmd == LINE_CMD_EOL) break; text = tmp-1; } } }
void gui_window_line_text_free(GUI_WINDOW_REC *gui, LINE_REC *line) { TEXT_CHUNK_REC *chunk; const char *text; text = line->text; for (;;) { if (*text == '\0') { text++; if ((unsigned char) *text == LINE_CMD_EOL) break; if ((unsigned char) *text == LINE_CMD_CONTINUE) { char *tmp; memcpy(&tmp, text+1, sizeof(char *)); /* free the previous block */ chunk = text_chunk_find(gui, text); if (--chunk->lines == 0) text_chunk_free(gui, chunk); text = tmp; continue; } if ((unsigned char) *text & 0x80) text++; continue; } text++; } /* free the last block */ chunk = text_chunk_find(gui, text); if (--chunk->lines == 0) { if (gui->cur_text == chunk) chunk->pos = 0; else text_chunk_free(gui, chunk); } }