guile-devel
[Top][All Lists]
Advanced

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

Re: proposal: scm_string2str() and scm_symbol2str()


From: Dirk Herrmann
Subject: Re: proposal: scm_string2str() and scm_symbol2str()
Date: Mon, 20 Nov 1995 20:24:26 +0100 (MET)

On Mon, 19 Nov 2001, stefan wrote:

> > >  * 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().

Sorry, I don't get it.  If guile allocates the memory using malloc, then
it would use the libc implementation of malloc, wouldn't it?  How could
there be a conflict if the user used free on that memory?

> > >  * 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().  

OK, I see your point.

> > >    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?

Yes.

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

I have never used any of those, that is why I don't care too much about
them :-)

Best regards
Dirk Herrmann




reply via email to

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