From 4c9419ac31f8364db51ccf25f7f9d5d31dd412e7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 11 Feb 2002 18:06:50 +0000 Subject: * gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when non-zero is returned from a port or smob free function. (scm_malloc, scm_realloc, scm_strndup, scm_strdup, scm_gc_register_collectable_memory, scm_gc_unregister_collectable_memory, scm_gc_malloc, scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New. * backtrace.c, continuations.c, convert.i.c, coop-threads.c, debug-malloc.c, dynl.c, environments.c, environments.h, extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c, guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c, ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c, smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c, vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and scm_gc_free/free instead of scm_must_malloc and scm_must_free, as appropriate. Return zero from smob and port free functions. * debug-malloc.c (scm_malloc_reregister): Handle "old == NULL". * fports.c (scm_setvbuf): Reset read buffer to saved values when it is pointing to the putback buffer. --- libguile/struct.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'libguile/struct.c') diff --git a/libguile/struct.c b/libguile/struct.c index 9d75e43f0..a384c8647 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -306,10 +306,10 @@ SCM_DEFINE (scm_struct_vtable_p, "struct-vtable?", 1, 0, 0, scm_t_bits * -scm_alloc_struct (int n_words, int n_extra, char *who) +scm_alloc_struct (int n_words, int n_extra, const char *what) { int size = sizeof (scm_t_bits) * (n_words + n_extra) + 7; - void * block = scm_must_malloc (size, who); + void * block = scm_gc_malloc (size, what); /* Adjust the pointer to hide the extra words. */ scm_t_bits * p = (scm_t_bits *) block + n_extra; @@ -326,36 +326,33 @@ scm_alloc_struct (int n_words, int n_extra, char *who) return p; } -size_t +void scm_struct_free_0 (scm_t_bits * vtable SCM_UNUSED, scm_t_bits * data SCM_UNUSED) { - return 0; } -size_t +void scm_struct_free_light (scm_t_bits * vtable, scm_t_bits * data) { - scm_must_free (data); - return vtable [scm_struct_i_size] & ~SCM_STRUCTF_MASK; + size_t n = vtable [scm_struct_i_size] & ~SCM_STRUCTF_MASK; + scm_gc_free (data, n, "struct"); } -size_t +void scm_struct_free_standard (scm_t_bits * vtable SCM_UNUSED, scm_t_bits * data) { size_t n = (data[scm_struct_i_n_words] + scm_struct_n_extra_words) * sizeof (scm_t_bits) + 7; - scm_must_free ((void *) data[scm_struct_i_ptr]); - return n; + scm_gc_free ((void *) data[scm_struct_i_ptr], n, "heavy struct"); } -size_t +void scm_struct_free_entity (scm_t_bits * vtable SCM_UNUSED, scm_t_bits * data) { size_t n = (data[scm_struct_i_n_words] + scm_struct_entity_n_extra_words) * sizeof (scm_t_bits) + 7; - scm_must_free ((void *) data[scm_struct_i_ptr]); - return n; + scm_gc_free ((void *) data[scm_struct_i_ptr], n, "entity struct"); } static void * @@ -455,14 +452,14 @@ SCM_DEFINE (scm_make_struct, "make-struct", 2, 0, 1, { data = scm_alloc_struct (basic_size + tail_elts, scm_struct_entity_n_extra_words, - "make-struct"); + "entity struct"); data[scm_struct_i_procedure] = SCM_UNPACK (SCM_BOOL_F); data[scm_struct_i_setter] = SCM_UNPACK (SCM_BOOL_F); } else data = scm_alloc_struct (basic_size + tail_elts, scm_struct_n_extra_words, - "make-struct"); + "struct"); handle = scm_alloc_double_cell ((((scm_t_bits) SCM_STRUCT_DATA (vtable)) + scm_tc3_struct), (scm_t_bits) data, 0, 0); @@ -541,7 +538,7 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1, SCM_DEFER_INTS; data = scm_alloc_struct (basic_size + tail_elts, scm_struct_n_extra_words, - "make-vtable-vtable"); + "struct"); handle = scm_alloc_double_cell ((scm_t_bits) data + scm_tc3_struct, (scm_t_bits) data, 0, 0); data [scm_vtable_index_layout] = SCM_UNPACK (layout); -- cgit v1.2.3