diff options
author | Ludovic Courtès <ludo@gnu.org> | 2009-01-18 16:13:31 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2009-01-18 16:13:31 +0100 |
commit | 1a531c80b2d4d57ae80b0515e66e03efa18bb938 (patch) | |
tree | d6f987e2fe1a385c9209e49065cfc825ff9d9d30 /libguile/hooks.c | |
parent | 2a77682322b3d466ac16ce4bd1244d29085a3555 (diff) | |
download | guile-1a531c80b2d4d57ae80b0515e66e03efa18bb938.tar.gz |
Use `scm_gc_malloc ()' when allocating hook entries.
* libguile/hooks.c (hook_entry_gc_hint): New.
(scm_c_hook_add): Use `scm_gc_malloc ()' instead of `scm_malloc ()'.
(scm_c_hook_remove): Don't explicitly free(3) the entry, let the GC do
its job.
Diffstat (limited to 'libguile/hooks.c')
-rw-r--r-- | libguile/hooks.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libguile/hooks.c b/libguile/hooks.c index aa8015144..d175be127 100644 --- a/libguile/hooks.c +++ b/libguile/hooks.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,6 +42,9 @@ * using C level hooks. */ +/* Hint for `scm_gc_malloc ()' and friends. */ +static const char hook_entry_gc_hint[] = "hook entry"; + void scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type) { @@ -56,8 +59,10 @@ scm_c_hook_add (scm_t_c_hook *hook, void *fn_data, int appendp) { - scm_t_c_hook_entry *entry = scm_malloc (sizeof (scm_t_c_hook_entry)); + scm_t_c_hook_entry *entry; scm_t_c_hook_entry **loc = &hook->first; + + entry = scm_gc_malloc (sizeof (scm_t_c_hook_entry), hook_entry_gc_hint); if (appendp) while (*loc) loc = &(*loc)->next; @@ -77,9 +82,7 @@ scm_c_hook_remove (scm_t_c_hook *hook, { if ((*loc)->func == func && (*loc)->data == fn_data) { - scm_t_c_hook_entry *entry = *loc; *loc = (*loc)->next; - free (entry); return; } loc = &(*loc)->next; |