guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SCM_STRING_CHARS is deprecated. See the manual for alternatives.


From: Bruce Korb
Subject: SCM_STRING_CHARS is deprecated. See the manual for alternatives.
Date: Sat, 16 Sep 2006 14:46:53 -0700
User-agent: Mozilla Thunderbird 1.0.7 (X11/20050923)

Hi,

I've seen the manual.  For Guile 1.8 it says:

 -- Macro: char * SCM_STRING_CHARS (SCM X)
 -- Macro: char * SCM_SYMBOL_CHARS (SCM X)
     Return a pointer to the characters of X.  The result is undefined
     if X is not a symbol or string, respectively.

   There are also a few magic values stuffed into memory before a
symbol's characters, but you don't want to know about those.  What
cruft!

   Note that `SCM_VECTOR_BASE', `SCM_STRING_CHARS' and
`SCM_SYMBOL_CHARS' return pointers to data within the respective
object.  Care must be taken that the object is not garbage collected
while that data is still being accessed.  This is the same as for a
smob, *Note Remembering During Operations::.


Here's the deal:  I just want access to the array of characters.
I've never presumed the characters are NUL terminated.  Now,
I am getting this message and the code itself says:

static SCM
make_stringbuf (size_t len)
{
  /* XXX - for the benefit of SCM_STRING_CHARS, SCM_SYMBOL_CHARS and
     scm_i_symbol_chars, all stringbufs are null-terminated.  Once
     SCM_STRING_CHARS and SCM_SYMBOL_CHARS are removed and the code
     has been changed for scm_i_symbol_chars, this null-termination
     can be dropped.
  */

Unfortunately, it seems to take a lot of grubbing around in the
source code to find out how to do this.  I am completely aware of
the fact that any call to any Guile function can invalidate an
address gotten via this mechanism.  However, with a single threaded
program and without making such a call, I know the address will
remain valid.  I want it.  It saves a lot of allocate, copy & free
bother.  Thank you!  Regards, bruce




reply via email to

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