[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proposal: scm_string2str() and scm_symbol2str()
From: |
stefan |
Subject: |
Re: proposal: scm_string2str() and scm_symbol2str() |
Date: |
Mon, 19 Nov 2001 20:03:57 +0100 (CET) |
On Mon, 20 Nov 1995, Dirk Herrmann wrote:
> On Fri, 16 Nov 2001, stefan wrote:
>
> > If noone objects I would like to put the following piece into the
> > "Decisions" section:
> >
> > * To have sane memory allocation interface between C and libguile
> > put scm_c_free(), scm_c_malloc() and scm_c_realloc() into `gc.[ch]'.
>
> What would these functions do?
/* Memory allocation functions: Used within the `SCM -> C array type'
conversion functions. These should be used instead of the standard
malloc(), free() and realloc() functions provided by any underlying
libc implementation. It avoids problems with applications using a
installed Guile library (libguile) and which use a different libc
implementation. */
Thus these functions are very simple wrappers for free(), malloc() and
realloc().
> > * Convert and implement these gh_*() functionality:
> > gh_scm2newstr() ->
> > char *scm_c_string2str (SCM obj, char *str, size_t *lenp)
>
> I suggest to name this function scm_c_string2mem. The reason is, that it
> may hold \0 characters. And, for those conversions that work the other
> way around we have chosen to use 'mem' for char*/size_t pairs, and str for
> zero terminated character arrays.
The scm_c_string2str() function is meant to do make a copy of a string
(including \0 characters) with a trailing \0 in order to simplify the
usage of the function at C level if you don't care about the *LENP
argument. That is why I thought we should name it scm_c_string2str().
So we need a third vote? :-)
> > gh_scm2newsymbol() ->
> > char *scm_c_symbol2str (SCM obj, char *str, size_t *lenp)
>
> Same as above: scm_c_symbol2mem
I agree if ... same as above.
> > gh_get_substr() ->
> > char *scm_c_string2substr (SCM obj, char *str, size_t start, size_t len)
>
> Hmmm. This should rather be named scm_c_substring2mem, shouldn't it?
Yes. Or scm_c_substring2str?
> > gh_scm2chars() ->
> > char *scm_c_scm2chars (SCM obj, char *dst)
> > gh_scm2shorts() ->
> > short *scm_2_scm2shorts (SCM obj, short *dst)
> > gh_scm2longs() ->
> > long *scm_c_scm2longs (SCM obj, long *dst)
> > gh_scm2floats() ->
> > float *scm_c_scm2floats (SCM obj, float *dst)
> > gh_scm2doubles() ->
> > double *scm_c_scm2doubles (SCM obj, double *dst)
These should convert a vector, weak vector, string, substring or uniform
vector (whatever makes sense) into a C array.
Cheers,
address@hidden
- proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/12
- Re: proposal: scm_string2str() and scm_symbol2str(), Thien-Thi Nguyen, 2001/11/12
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/19
- Re: proposal: scm_string2str() and scm_symbol2str(),
stefan <=
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/19
- Re: proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/19
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/21
- Re: proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/21
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/21
- Re: proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/22
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/22
- Re: proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/22
- Re: proposal: scm_string2str() and scm_symbol2str(), Dirk Herrmann, 2001/11/25
- Re: proposal: scm_string2str() and scm_symbol2str(), stefan, 2001/11/26