[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_* equivalent of gh_scm2newstr
From: |
Dave Lambert |
Subject: |
Re: scm_* equivalent of gh_scm2newstr |
Date: |
Mon, 03 Sep 2001 06:41:50 -0400 |
>>>>> " " == Martin Baulig <address@hidden> writes:
| But for gh_scm2newstr there is already a replacement: SCM_STRING_CHARS()
| and SCM_SYMBOL_CHARS() - except that they don't copy the string - but is
| this really a problem, as you can just strdup() the result ?
My first thought, too. But Scheme strings may contain null
characters, so strdup only copies part of the string. To do it
properly, you have to malloc enough memory for SCM_STRING_LENGTH(),
and copy it. Oh, and null terminate _that_. Not a great deal of
work, but I'm lazy.
| So we probably need some scm_str2string() and scm_str2symbol() - and choose
| a better name for them - IMO it's very inconvenient that you always need to
| specify the length, especially if you have code like
| scm_mem2symbol (some_array [j].struct_field,
| strlen (some_array [j].struct_field));
Dealing with the length does get annoying. Perhaps if the length
argument (or the pointer to it) were 0, the SCM_ functions might
default to treating the string as one containing no non-terminating
NULLs? This would almost always be the case from C.
Dave
--
programmer, n:
A red eyed, mumbling mammal capable of conversing with inanimate
monsters.
- Re: scm_* equivalent of gh_scm2newstr, Marius Vollmer, 2001/09/01
- Re: scm_* equivalent of gh_scm2newstr, Martin Baulig, 2001/09/01
- Re: scm_* equivalent of gh_scm2newstr, Dirk Herrmann, 2001/09/02
- Re: scm_* equivalent of gh_scm2newstr, Martin Baulig, 2001/09/02
- Re: scm_* equivalent of gh_scm2newstr,
Dave Lambert <=
- Re: scm_* equivalent of gh_scm2newstr, Dirk Herrmann, 2001/09/03
- Re: scm_* equivalent of gh_scm2newstr, Martin Baulig, 2001/09/04
- Re: scm_* equivalent of gh_scm2newstr, Martin Baulig, 2001/09/07
- Re: scm_* equivalent of gh_scm2newstr, Dirk Herrmann, 2001/09/12