From 1a531c80b2d4d57ae80b0515e66e03efa18bb938 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 18 Jan 2009 16:13:31 +0100 Subject: 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. --- libguile/hooks.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libguile/hooks.c') 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; -- cgit v1.2.3