diff options
author | Andy Wingo <wingo@pobox.com> | 2011-08-18 11:54:20 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-08-18 12:53:28 +0200 |
commit | fb031aba42d3b0d22538c50ef92a666496a8e326 (patch) | |
tree | 2cfd00b5c5d5580037116fcdac1d9a702429fb3d | |
parent | 5261e74281b1150e3b2594c92e571d8887a4900d (diff) | |
download | guile-fb031aba42d3b0d22538c50ef92a666496a8e326.tar.gz |
fix a couple of leaks
* libguile/bytevectors.h:
* libguile/bytevectors.c (scm_c_take_gc_bytevector): Rename this
internal function, from scm_c_take_bytevector. This indicates that
unlike the other scm_take_* functions, this one takes GC-managed
memory.
* libguile/objcodes.c (scm_objcode_to_bytecode):
* libguile/vm.c (really_make_boot_program): Use
scm_gc_malloc_pointerless, not scm_malloc. Thanks to Stefan
Israelsson Tampe!
* libguile/r6rs-ports.c:
* libguile/strings.c: Adapt to renames.
-rw-r--r-- | libguile/bytevectors.c | 2 | ||||
-rw-r--r-- | libguile/bytevectors.h | 4 | ||||
-rw-r--r-- | libguile/objcodes.c | 4 | ||||
-rw-r--r-- | libguile/r6rs-ports.c | 10 | ||||
-rw-r--r-- | libguile/strings.c | 2 | ||||
-rw-r--r-- | libguile/vm.c | 7 |
6 files changed, 15 insertions, 14 deletions
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index 14159d28d..4aeae63b0 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -285,7 +285,7 @@ scm_i_make_typed_bytevector (size_t len, scm_t_array_element_type element_type) /* Return a bytevector of size LEN made up of CONTENTS. The area pointed to by CONTENTS must have been allocated using `scm_gc_malloc ()'. */ SCM -scm_c_take_bytevector (signed char *contents, size_t len) +scm_c_take_gc_bytevector (signed char *contents, size_t len) { return make_bytevector_from_buffer (len, contents, SCM_ARRAY_ELEMENT_TYPE_VU8); } diff --git a/libguile/bytevectors.h b/libguile/bytevectors.h index 431b7dddd..8bafff3a3 100644 --- a/libguile/bytevectors.h +++ b/libguile/bytevectors.h @@ -1,7 +1,7 @@ #ifndef SCM_BYTEVECTORS_H #define SCM_BYTEVECTORS_H -/* Copyright (C) 2009 Free Software Foundation, Inc. +/* Copyright (C) 2009, 2011 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 License @@ -138,7 +138,7 @@ SCM_INTERNAL void scm_bootstrap_bytevectors (void); SCM_INTERNAL void scm_init_bytevectors (void); SCM_INTERNAL SCM scm_i_native_endianness; -SCM_INTERNAL SCM scm_c_take_bytevector (signed char *, size_t); +SCM_INTERNAL SCM scm_c_take_gc_bytevector (signed char *, size_t); SCM_INTERNAL int scm_i_print_bytevector (SCM, SCM, scm_print_state *); diff --git a/libguile/objcodes.c b/libguile/objcodes.c index 526751acc..6223362f4 100644 --- a/libguile/objcodes.c +++ b/libguile/objcodes.c @@ -315,10 +315,10 @@ SCM_DEFINE (scm_objcode_to_bytecode, "objcode->bytecode", 1, 0, 0, len = sizeof (struct scm_objcode) + SCM_OBJCODE_TOTAL_LEN (objcode); - s8vector = scm_malloc (len); + s8vector = scm_gc_malloc_pointerless (len, FUNC_NAME); memcpy (s8vector, SCM_OBJCODE_DATA (objcode), len); - return scm_c_take_bytevector (s8vector, len); + return scm_c_take_gc_bytevector (s8vector, len); } #undef FUNC_NAME diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index 6eff97d5b..e8674299d 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -618,7 +618,7 @@ SCM_DEFINE (scm_get_bytevector_some, "get-bytevector-some", 1, 0, 0, c_len = (unsigned) c_total; } - result = scm_c_take_bytevector ((signed char *) c_bv, c_len); + result = scm_c_take_gc_bytevector ((signed char *) c_bv, c_len); } return result; @@ -677,7 +677,7 @@ SCM_DEFINE (scm_get_bytevector_all, "get-bytevector-all", 1, 0, 0, c_len = (unsigned) c_total; } - result = scm_c_take_bytevector ((signed char *) c_bv, c_len); + result = scm_c_take_gc_bytevector ((signed char *) c_bv, c_len); } return result; @@ -919,7 +919,7 @@ SCM_SMOB_APPLY (bytevector_output_port_procedure, bop_buffer_init (buf); if (result_buf.len == 0) - bv = scm_c_take_bytevector (NULL, 0); + bv = scm_c_take_gc_bytevector (NULL, 0); else { if (result_buf.total_len > result_buf.len) @@ -929,8 +929,8 @@ SCM_SMOB_APPLY (bytevector_output_port_procedure, result_buf.len, SCM_GC_BOP); - bv = scm_c_take_bytevector ((signed char *) result_buf.buffer, - result_buf.len); + bv = scm_c_take_gc_bytevector ((signed char *) result_buf.buffer, + result_buf.len); } return bv; diff --git a/libguile/strings.c b/libguile/strings.c index 24c82fc3e..5b15ddcb3 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -1489,7 +1489,7 @@ scm_from_stringn (const char *str, size_t len, const char *encoding, buf = scm_gc_malloc_pointerless (len, "bytevector"); memcpy (buf, str, len); - bv = scm_c_take_bytevector (buf, len); + bv = scm_c_take_gc_bytevector (buf, len); scm_decoding_error (__func__, errno, "input locale conversion error", bv); diff --git a/libguile/vm.c b/libguile/vm.c index b9d613a96..6cb85b772 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -384,13 +384,14 @@ really_make_boot_program (long nargs) text[1] = (scm_t_uint8)nargs; - bp = scm_malloc (sizeof (struct scm_objcode) + sizeof (text)); + bp = scm_gc_malloc_pointerless (sizeof (struct scm_objcode) + sizeof (text), + "boot-program"); memcpy (SCM_C_OBJCODE_BASE (bp), text, sizeof (text)); bp->len = sizeof(text); bp->metalen = 0; - u8vec = scm_c_take_bytevector ((scm_t_int8*)bp, - sizeof (struct scm_objcode) + sizeof (text)); + u8vec = scm_c_take_gc_bytevector ((scm_t_int8*)bp, + sizeof (struct scm_objcode) + sizeof (text)); ret = scm_make_program (scm_bytecode_to_objcode (u8vec), SCM_BOOL_F, SCM_BOOL_F); SCM_SET_CELL_WORD_0 (ret, SCM_CELL_WORD_0 (ret) | SCM_F_PROGRAM_IS_BOOT); |