void save(GtkWidget *widget, gpointer data) { NEW_DATA *new_data = (NEW_DATA*) data; R2RDatabase *database = new_data->database; R2RRun *new_run = new_data->newrun; gint edit = new_data->edit_index; /* setting notes here because we don't have a separate save button */ set_notes(new_run, new_data->notes_buff); if (edit < 0) { //new run /* Append the new run to the database */ database->nruns++; database->run = g_realloc(database->run, database->nruns * sizeof(R2RRun*)); database->run[database->nruns - 1] = g_malloc(sizeof(R2RRun)); memcpy(database->run[database->nruns - 1], new_run, sizeof(R2RRun)); printf("new_run = %p\n", new_run); int i; for (i = 0; i < database->nruns; i++) { printf("run[%i] = %p\n", i, database->run[i]); } } else { //edit existing run /* Replace the indexed run with the "new run" */ memcpy(database->run[edit], new_run, sizeof(R2RRun)); } /* Either way, we need to allocate a new new run */ gtk_widget_hide(GTK_WIDGET(new_data->newrun_window)); }
Mark_mmdb::Mark_mmdb (MarkBase_mmdb &base, UAS_Pointer<UAS_Common> &doc_ptr, const Anchor &anchor, const char *name, const char *notes) : f_doc_ptr (doc_ptr), f_anchor (anchor), f_mark_base (base), f_name (NULL), f_notes (NULL) { // This creates a new user mark in the mmdb mark database. #ifdef FUJITSU_OLIAS // Id = bookcase id / section id UAS_String theId = doc_ptr->bid(); theId = theId + "/" + doc_ptr->id(); #else UAS_String theId = doc_ptr->id(); #endif f_user_mark = new mark_smart_ptr (base, theId); set_name (name); set_notes (notes); // Flush the new mark to disk. do_save(); }