mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
Fix leaky handling of `scm_take_locale_{symbol,string} ()'.
* libguile/strings.c (scm_i_take_stringbufn, scm_i_c_take_symbol): Remove. (scm_take_locale_stringn): Rewrite in terms of `scm_from_locale_stringn ()'. * libguile/strings.h (scm_i_c_take_symbol, scm_i_take_stringbufn): Remove declarations.
This commit is contained in:
parent
4812ce85dd
commit
13a9455669
2 changed files with 6 additions and 41 deletions
|
@ -164,17 +164,6 @@ make_wide_stringbuf (size_t len)
|
||||||
(scm_t_bits) len, (scm_t_bits) 0);
|
(scm_t_bits) len, (scm_t_bits) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a new stringbuf whose underlying storage consists of the LEN+1
|
|
||||||
octets pointed to by STR (the last octet is zero). */
|
|
||||||
SCM
|
|
||||||
scm_i_take_stringbufn (char *str, size_t len)
|
|
||||||
{
|
|
||||||
scm_gc_register_collectable_memory (str, len + 1, "stringbuf");
|
|
||||||
|
|
||||||
return scm_double_cell (STRINGBUF_TAG, (scm_t_bits) str,
|
|
||||||
(scm_t_bits) len, (scm_t_bits) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert a stringbuf containing 8-bit Latin-1-encoded characters to
|
/* Convert a stringbuf containing 8-bit Latin-1-encoded characters to
|
||||||
one containing 32-bit UCS-4-encoded characters. */
|
one containing 32-bit UCS-4-encoded characters. */
|
||||||
static void
|
static void
|
||||||
|
@ -744,18 +733,6 @@ scm_i_c_make_symbol (const char *name, size_t len,
|
||||||
(scm_t_bits) hash, SCM_UNPACK (props));
|
(scm_t_bits) hash, SCM_UNPACK (props));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a new symbol that uses the LEN bytes pointed to by NAME as its
|
|
||||||
underlying storage. */
|
|
||||||
SCM
|
|
||||||
scm_i_c_take_symbol (char *name, size_t len,
|
|
||||||
scm_t_bits flags, unsigned long hash, SCM props)
|
|
||||||
{
|
|
||||||
SCM buf = scm_i_take_stringbufn (name, len);
|
|
||||||
|
|
||||||
return scm_double_cell (scm_tc7_symbol | flags, SCM_UNPACK (buf),
|
|
||||||
(scm_t_bits) hash, SCM_UNPACK (props));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns the number of characters in SYM. This may be different
|
/* Returns the number of characters in SYM. This may be different
|
||||||
from the memory size of SYM. */
|
from the memory size of SYM. */
|
||||||
size_t
|
size_t
|
||||||
|
@ -1556,25 +1533,17 @@ scm_i_from_utf8_string (const scm_t_uint8 *str)
|
||||||
|
|
||||||
/* Create a new scheme string from the C string STR. The memory of
|
/* Create a new scheme string from the C string STR. The memory of
|
||||||
STR may be used directly as storage for the new string. */
|
STR may be used directly as storage for the new string. */
|
||||||
|
/* FIXME: GC-wise, the only way to use the memory area pointed to by STR
|
||||||
|
would be to register a finalizer to eventually free(3) STR, which isn't
|
||||||
|
worth it. Should we just deprecate the `scm_take_' functions? */
|
||||||
SCM
|
SCM
|
||||||
scm_take_locale_stringn (char *str, size_t len)
|
scm_take_locale_stringn (char *str, size_t len)
|
||||||
{
|
{
|
||||||
SCM buf, res;
|
SCM res;
|
||||||
|
|
||||||
if (len == (size_t) -1)
|
res = scm_from_locale_stringn (str, len);
|
||||||
len = strlen (str);
|
free (str);
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ensure STR is null terminated. A realloc for 1 extra byte should
|
|
||||||
often be satisfied from the alignment padding after the block, with
|
|
||||||
no actual data movement. */
|
|
||||||
str = scm_realloc (str, len + 1);
|
|
||||||
str[len] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = scm_i_take_stringbufn (str, len);
|
|
||||||
res = scm_double_cell (STRING_TAG,
|
|
||||||
SCM_UNPACK (buf), (scm_t_bits) 0, (scm_t_bits) len);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,9 +164,6 @@ SCM_INTERNAL SCM scm_i_make_symbol (SCM name, scm_t_bits flags,
|
||||||
SCM_INTERNAL SCM
|
SCM_INTERNAL SCM
|
||||||
scm_i_c_make_symbol (const char *name, size_t len,
|
scm_i_c_make_symbol (const char *name, size_t len,
|
||||||
scm_t_bits flags, unsigned long hash, SCM props);
|
scm_t_bits flags, unsigned long hash, SCM props);
|
||||||
SCM_INTERNAL SCM
|
|
||||||
scm_i_c_take_symbol (char *name, size_t len,
|
|
||||||
scm_t_bits flags, unsigned long hash, SCM props);
|
|
||||||
SCM_INTERNAL const char *scm_i_symbol_chars (SCM sym);
|
SCM_INTERNAL const char *scm_i_symbol_chars (SCM sym);
|
||||||
SCM_INTERNAL const scm_t_wchar *scm_i_symbol_wide_chars (SCM sym);
|
SCM_INTERNAL const scm_t_wchar *scm_i_symbol_wide_chars (SCM sym);
|
||||||
SCM_INTERNAL size_t scm_i_symbol_length (SCM sym);
|
SCM_INTERNAL size_t scm_i_symbol_length (SCM sym);
|
||||||
|
@ -181,7 +178,6 @@ SCM_INTERNAL char **scm_i_allocate_string_pointers (SCM list);
|
||||||
SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
|
SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
|
||||||
SCM start, size_t *cstart,
|
SCM start, size_t *cstart,
|
||||||
SCM end, size_t *cend);
|
SCM end, size_t *cend);
|
||||||
SCM_INTERNAL SCM scm_i_take_stringbufn (char *str, size_t len);
|
|
||||||
|
|
||||||
/* Debugging functions */
|
/* Debugging functions */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue