This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pass by value and also snprintf()


Hi Richard,  THANK YOU!!

> That would be because you're passing buffer and fmt instead of a pointer to
> buffer and fmt.  You need to do
>
>         char *     buffer_p = buffer;
>         const char *fmt_p = fmt;
>
>         void * values[5] = {
>                 [0] = &buffer_p,
>                 [1] = &bufsz,
>                 [2] = &fmt_p,
>                 [3] = &sblock,
>                 [4] = &band };
>
> One of the many peculiarities of the libffi api...

Indeed.  Worthy of a BOLD caveat in the docs.
Googling seems to point mostly here:
http://www.atmark-techno.com/~yashi/libffi.html
but it looks like my info doc, so I hope it is up to date.  Anyway, it was there
where I also saw that funny comment about altering passed values.
Based on my understanding of C and calling conventions, it seems pretty
impossible for a callee to alter a caller's value when passed by value, even if
one goes through libffi, so what is that comment trying to say?  (RE:
ffi_call())

Anyway, again, thank you!  Regards, Bruce


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]