guile-devel
[Top][All Lists]
Advanced

[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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]