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

* gc.h, gc.c (scm_must_strdup, scm_must_strndup): New.

This commit is contained in:
Marius Vollmer 2001-05-20 19:27:22 +00:00
parent e2ab7927bf
commit e4a7824f4e
2 changed files with 16 additions and 0 deletions

View file

@ -1985,6 +1985,20 @@ scm_must_realloc (void *where,
scm_memory_error (what);
}
char *
scm_must_strndup (const char *str, unsigned long length)
{
char * dst = scm_must_malloc (length + 1, "scm_must_strndup");
memcpy (dst, str, length);
dst[length] = 0;
return dst;
}
char *
scm_must_strdup (const char *str)
{
return scm_must_strndup (str, strlen (str));
}
void
scm_must_free (void *obj)

View file

@ -370,6 +370,8 @@ extern void * scm_must_malloc (scm_sizet len, const char *what);
extern void * scm_must_realloc (void *where,
scm_sizet olen, scm_sizet len,
const char *what);
extern char *scm_must_strdup (const char *str);
extern char *scm_must_strndup (const char *str, unsigned long n);
extern void scm_done_malloc (long size);
extern void scm_done_free (long size);
extern void scm_must_free (void *obj);