mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
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.
This commit is contained in:
parent
2a77682322
commit
1a531c80b2
1 changed files with 7 additions and 4 deletions
|
@ -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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -42,6 +42,9 @@
|
||||||
* using C level hooks.
|
* using C level hooks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Hint for `scm_gc_malloc ()' and friends. */
|
||||||
|
static const char hook_entry_gc_hint[] = "hook entry";
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type)
|
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,
|
void *fn_data,
|
||||||
int appendp)
|
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;
|
scm_t_c_hook_entry **loc = &hook->first;
|
||||||
|
|
||||||
|
entry = scm_gc_malloc (sizeof (scm_t_c_hook_entry), hook_entry_gc_hint);
|
||||||
if (appendp)
|
if (appendp)
|
||||||
while (*loc)
|
while (*loc)
|
||||||
loc = &(*loc)->next;
|
loc = &(*loc)->next;
|
||||||
|
@ -77,9 +82,7 @@ scm_c_hook_remove (scm_t_c_hook *hook,
|
||||||
{
|
{
|
||||||
if ((*loc)->func == func && (*loc)->data == fn_data)
|
if ((*loc)->func == func && (*loc)->data == fn_data)
|
||||||
{
|
{
|
||||||
scm_t_c_hook_entry *entry = *loc;
|
|
||||||
*loc = (*loc)->next;
|
*loc = (*loc)->next;
|
||||||
free (entry);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loc = &(*loc)->next;
|
loc = &(*loc)->next;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue