1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Andy Wingo 2011-08-18 11:54:20 +02:00
parent 5261e74281
commit fb031aba42
6 changed files with 15 additions and 14 deletions

View file

@ -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);
}

View file

@ -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 *);

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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);