#define SET_STRING_STRINGBUF(str,buf) (SCM_SET_CELL_OBJECT_1(str,buf))
#define SET_STRING_START(str,start) (SCM_SET_CELL_WORD_2(str,start))
-#define IS_STRING(str) (SCM_NIMP(str) && SCM_TYP7(str) == STRING_TAG)
+#define IS_STRING(str) (SCM_HAS_TYP7 (str, STRING_TAG))
/* Read-only strings.
*/
buf = scm_gc_malloc_pointerless (len, "bytevector");
memcpy (buf, str, len);
- bv = scm_c_take_bytevector (buf, len, SCM_BOOL_F);
+ bv = scm_c_take_gc_bytevector (buf, len, SCM_BOOL_F);
scm_decoding_error (__func__, errno,
"input locale conversion error", bv);
if (scm_i_is_narrow_string (str))
{
+ size_t len = scm_i_string_length (str);
+
if (lenp)
- *lenp = scm_i_string_length (str);
+ *lenp = len;
- result = scm_strdup (scm_i_string_data (str));
+ result = scm_strndup (scm_i_string_data (str), len);
}
else
result = scm_to_stringn (str, lenp, NULL,
- SCM_FAILED_CONVERSION_ERROR);
+ SCM_FAILED_CONVERSION_ERROR);
return result;
}