gint hex_document_read(HexDocument *doc) { FILE *file; static HexChangeData change_data; if(doc->file_name == NULL) return FALSE; if(!get_document_attributes(doc)) return FALSE; if((file = fopen(doc->file_name, "r")) == NULL) return FALSE; doc->gap_size = doc->buffer_size - doc->file_size; if(fread(doc->buffer + doc->gap_size, 1, doc->file_size, file) != doc->file_size) { g_return_val_if_reached(FALSE); } doc->gap_pos = doc->buffer; fclose(file); undo_stack_free(doc); change_data.start = 0; change_data.end = doc->file_size - 1; doc->changed = FALSE; hex_document_changed(doc, &change_data, FALSE); return TRUE; }
static void hex_document_finalize(GObject *obj) { HexDocument *hex; hex = HEX_DOCUMENT(obj); if(hex->buffer) g_free(hex->buffer); if(hex->file_name) g_free(hex->file_name); if(hex->path_end) g_free(hex->path_end); undo_stack_free(hex); while(hex->views) hex_document_remove_view(hex, (GtkWidget *)hex->views->data); doc_list = g_list_remove(doc_list, hex); G_OBJECT_CLASS (parent_class)->finalize (obj); }
void hex_document_set_max_undo(HexDocument *doc, guint max_undo) { if(doc->undo_max != max_undo) { if(doc->undo_max > max_undo) undo_stack_free(doc); doc->undo_max = max_undo; } }
void ED_undo_paint_free(void) { undo_stack_free(&ImageUndoStack); undo_stack_free(&MeshUndoStack); }