From d0cad2492cd880fded45b4ab52afb61e6047b1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 18 Jan 2009 16:30:36 +0100 Subject: [PATCH] Use `scm_gc_malloc ()' when allocating GOOPS `t_extension' objects. * libguile/goops.c (extension_gc_hint): New. (scm_c_extend_primitive_generic): Use `scm_gc_malloc ()' instead of `scm_malloc ()'. (setup_extended_primitive_generics): Don't call `free(3)' when removing a `t_extension' object. --- libguile/goops.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libguile/goops.c b/libguile/goops.c index ac3df6505..1bd56a9f0 100644 --- a/libguile/goops.c +++ b/libguile/goops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008 +/* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2008,2009 * Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or @@ -1879,6 +1879,11 @@ typedef struct t_extension { SCM extension; } t_extension; + +/* Hint for `scm_gc_malloc ()' et al. when allocating `t_extension' + objects. */ +static const char extension_gc_hint[] = "GOOPS extension"; + static t_extension *extensions = 0; SCM_VARIABLE (scm_var_make_extended_generic, "make-extended-generic"); @@ -1899,7 +1904,8 @@ scm_c_extend_primitive_generic (SCM extended, SCM extension) } else { - t_extension *e = scm_malloc (sizeof (t_extension)); + t_extension *e = scm_gc_malloc (sizeof (t_extension), + extension_gc_hint); t_extension **loc = &extensions; /* Make sure that extensions are placed before their own * extensions in the extensions list. O(N^2) algorithm, but @@ -1922,7 +1928,6 @@ setup_extended_primitive_generics () t_extension *e = extensions; scm_c_extend_primitive_generic (e->extended, e->extension); extensions = e->next; - free (e); } }