unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* SCM_STRING_CHARS is deprecated.  See the manual for alternatives.
@ 2006-09-16 21:46 Bruce Korb
  2006-09-23 10:19 ` Neil Jerram
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Korb @ 2006-09-16 21:46 UTC (permalink / raw)


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


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread
* SCM_STRING_CHARS is deprecated.  See the manual for alternatives.
@ 2006-08-10  3:57 Bruce Korb
  2006-08-10  8:05 ` Neil Jerram
  2006-08-11  0:30 ` Kevin Ryde
  0 siblings, 2 replies; 6+ messages in thread
From: Bruce Korb @ 2006-08-10  3:57 UTC (permalink / raw)


Hi,

Um.  I did.  This is all I find:

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

==================================

* SCM_STRING_CHARS:                      Vector Data.         (line  36)



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-23 17:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-16 21:46 SCM_STRING_CHARS is deprecated. See the manual for alternatives Bruce Korb
2006-09-23 10:19 ` Neil Jerram
2006-09-23 17:04   ` Bruce Korb
  -- strict thread matches above, loose matches on Subject: below --
2006-08-10  3:57 Bruce Korb
2006-08-10  8:05 ` Neil Jerram
2006-08-11  0:30 ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).