Remove SCM registry. Use scm_protect_object instead.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2297 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-05-11 09:00:12 +00:00
parent ddaeed92f5
commit 17d7f041e9
7 changed files with 22 additions and 58 deletions

View File

@ -1,5 +1,8 @@
2000-05-10 Dave Peticolas <peticola@cs.ucdavis.edu>
* many: removed use of SCM registry in favor of scm_protect_object
and scm_unprotect_object.
* src/engine/GNCId.c (xaccRemoveEntity): don't allow the NULL id
to be removed.

View File

@ -62,7 +62,6 @@ struct _BudgetDialog
GtkWidget *apply_button;
SCM apply_func;
SCM apply_func_id;
SCM current_entry;
SCM current_subentry;
@ -86,14 +85,12 @@ typedef struct _BudgetEntry
{
EntryType type;
SCM entry;
SCM entry_id;
} BudgetEntry;
typedef struct _BudgetSubEntry
{
EntryType type;
SCM subentry;
SCM subentry_id;
} BudgetSubEntry;
typedef union
@ -218,7 +215,7 @@ destroy_subentry(gpointer data)
if (bse == NULL) return;
gnc_unregister_c_side_scheme_ptr_id(bse->subentry_id);
scm_unprotect_object(bse->subentry);
g_free(bse);
}
@ -230,7 +227,7 @@ destroy_entry(gpointer data)
if (be == NULL) return;
gnc_unregister_c_side_scheme_ptr_id(be->entry_id);
scm_unprotect_object(be->entry);
g_free(be);
}
@ -431,7 +428,7 @@ fill_subentries(GtkCTree *ctree, GtkCTreeNode *entry_node, SCM entry)
bse->type = BUDGET_SUBENTRY;
bse->subentry = subentry;
bse->subentry_id = gnc_register_c_side_scheme_ptr(subentry);
scm_protect_object(subentry);
gtk_ctree_node_set_row_data_full(ctree, node, bse, destroy_subentry);
@ -473,7 +470,7 @@ fill_entry_tree(GtkWidget *entry_tree, SCM budget)
be->type = BUDGET_ENTRY;
be->entry = entry;
be->entry_id = gnc_register_c_side_scheme_ptr(entry);
scm_protect_object(entry);
gtk_ctree_node_set_row_data_full(ctree, node, be, destroy_entry);
@ -1085,7 +1082,8 @@ budget_dialog_destroy(GtkObject *object,
BudgetDialog *bd)
{
bd->dialog = NULL;
gnc_unregister_c_side_scheme_ptr_id(bd->apply_func_id);
scm_unprotect_object(bd->apply_func);
g_free(bd);
}
@ -1114,7 +1112,7 @@ gnc_ui_budget_dialog_create(SCM budget, SCM apply_func)
GTK_SIGNAL_FUNC(budget_dialog_destroy), bd);
bd->apply_func = apply_func;
bd->apply_func_id = gnc_register_c_side_scheme_ptr(apply_func);
scm_protect_object(apply_func);
bd->budget_name_entry = gtk_object_get_data(bdo, "budget_name_entry");
gtk_signal_connect(GTK_OBJECT(bd->budget_name_entry), "changed",

View File

@ -34,7 +34,6 @@ typedef struct _ExtensionInfo ExtensionInfo;
struct _ExtensionInfo
{
SCM extension;
SCM extension_id;
GnomeUIInfo info[2];
@ -269,7 +268,8 @@ gnc_create_extension_info(SCM extension)
ext_info->info[0].pixmap_type = GNOME_APP_PIXMAP_NONE;
ext_info->info[1].type = GNOME_APP_UI_ENDOFINFO;
ext_info->extension_id = gnc_register_c_side_scheme_ptr(extension);
scm_protect_object(extension);
extension_list = g_slist_prepend(extension_list, ext_info);
return ext_info;
@ -281,7 +281,7 @@ cleanup_extension_info(gpointer extension_info, gpointer not_used)
{
ExtensionInfo *ext_info = extension_info;
gnc_unregister_c_side_scheme_ptr_id(ext_info->extension_id);
scm_unprotect_object(ext_info->extension);
g_free(ext_info->info[0].label);
g_free(ext_info->info[0].hint);

View File

@ -47,7 +47,6 @@ struct _GNCOptionSection
struct _GNCOptionDB
{
SCM guile_options;
SCM guile_options_id;
GSList *option_sections;
@ -118,7 +117,7 @@ gnc_option_db_new(SCM guile_options)
odb = g_new0(GNCOptionDB, 1);
odb->guile_options = guile_options;
odb->guile_options_id = gnc_register_c_side_scheme_ptr(guile_options);
scm_protect_object(guile_options);
odb->option_sections = NULL;
odb->options_dirty = FALSE;
@ -170,7 +169,7 @@ gnc_option_db_destroy(GNCOptionDB *odb)
{
option = option_node->data;
gnc_unregister_c_side_scheme_ptr_id(option->guile_option_id);
scm_unprotect_object(option->guile_option);
option_node = option_node->next;
}
@ -195,9 +194,8 @@ gnc_option_db_destroy(GNCOptionDB *odb)
option_dbs = NULL;
}
gnc_unregister_c_side_scheme_ptr_id(odb->guile_options_id);
scm_unprotect_object(odb->guile_options);
odb->guile_options = SCM_UNDEFINED;
odb->guile_options_id = SCM_UNDEFINED;
g_free(odb);
}
@ -1118,13 +1116,7 @@ _gnc_option_db_register_option(GNCOptionDBHandle handle, SCM guile_option)
option->widget = NULL;
/* Prevent guile from garbage collecting the option */
option->guile_option_id = gnc_register_c_side_scheme_ptr(guile_option);
if (option->guile_option_id == SCM_UNDEFINED)
{
g_free(option);
PERR("_gnc_option_db_register_option: couldn't register\n");
return;
}
scm_protect_object(guile_option);
/* Make the section structure */
section = g_new0(GNCOptionSection, 1);

View File

@ -38,9 +38,6 @@ struct _GNCOption
/* Handle to the scheme-side option */
SCM guile_option;
/* Identifier for unregistering */
SCM guile_option_id;
/* Flag to indicate change by the UI */
gboolean changed;

View File

@ -56,7 +56,6 @@ struct _ReportData
GtkWidget *option_dialog;
SCM rendering_thunk;
SCM rendering_thunk_id;
SCM change_callback_id;
};
@ -69,7 +68,6 @@ report_data_new()
report_data = g_new0(ReportData, 1);
report_data->rendering_thunk = SCM_UNDEFINED;
report_data->rendering_thunk_id = SCM_UNDEFINED;
report_data->change_callback_id = SCM_UNDEFINED;
return report_data;
@ -95,10 +93,9 @@ report_data_destroy(HTMLUserData user_data)
gtk_widget_destroy(report_data->option_dialog);
report_data->option_dialog = NULL;
if (report_data->rendering_thunk_id != SCM_UNDEFINED)
gnc_unregister_c_side_scheme_ptr_id(report_data->rendering_thunk_id);
if (report_data->rendering_thunk != SCM_UNDEFINED)
scm_unprotect_object(report_data->rendering_thunk);
report_data->rendering_thunk = SCM_UNDEFINED;
report_data->rendering_thunk_id = SCM_UNDEFINED;
g_free(report_data);
}
@ -114,11 +111,11 @@ static void
report_data_set_rendering_thunk(ReportData *report_data,
const SCM rendering_thunk)
{
if (report_data->rendering_thunk_id != SCM_UNDEFINED)
gnc_unregister_c_side_scheme_ptr_id(report_data->rendering_thunk_id);
if (report_data->rendering_thunk != SCM_UNDEFINED)
scm_unprotect_object(report_data->rendering_thunk);
report_data->rendering_thunk = rendering_thunk;
report_data->rendering_thunk_id = gnc_register_c_side_scheme_ptr(rendering_thunk);
scm_protect_object(rendering_thunk);
}
static void

View File

@ -17,29 +17,6 @@
(require 'hash-table)
(define gnc:register-c-side-scheme-ptr #f)
(define gnc:unregister-c-side-scheme-ptr-id #f)
(let ((next-registration-id 0)
;; Not sure this has to be prime, and not sure how large it needs
;; to be, but on both fronts, this should be fairly safe...
(pointer-storage (make-hash-table 313)))
(define (register-c-side-scheme-ptr ptr)
(let ((id next-registration-id))
(set! next-registration-id (+ next-registration-id 1))
(hashv-set! pointer-storage id ptr)
id))
(define (unregister-c-side-scheme-ptr-id id)
(if (hashv-ref pointer-storage id)
(hashv-remove! pointer-storage id)
(gnc:error "unregister-c-side-scheme-ptr-id: no such id\n")))
(set! gnc:register-c-side-scheme-ptr register-c-side-scheme-ptr)
(set! gnc:unregister-c-side-scheme-ptr-id unregister-c-side-scheme-ptr-id))
(define (gnc:error->string tag args)
(define (write-error port)
(if (and (list? args) (not (null? args)))