Re: Implementing an interface
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 14 Aug 2007 21:32:15 GMT
bcpkh <vanheerden.braam@xxxxxxxxx> wrote:
Think I found my problem though, even though the function's return
type is void one of the parameters passed to the function is a char**,
pointer to pointer, which is supposed to contain the version number of
my plug-in, a character string. I am not correctly allocating memory
in my function and I think, as you suggested, the calling process
probably does not check that I allocated the memory correctly and give
the segmentation error.
If the caller just expects a string with the version then you
may not have to allocate memory. Perhaps something like
void give_me_your_version_please( char ** version_string ) {
*version_string = "0.0.42"
}
will do since you set what 'version_string' points to to a
string literal that won't vanish until the library gets
unloaded. But, of course, you have to read the complete
documentation about what kind of memory the caller expects
to get returned via 'version_string', if there's any indi-
cation that the caller is going to modify that string or
that it will try to call free() on the pointer you gave it
then this won't do and you have to resort to using "real"
allocated memory.
I need to experiment a bit but feel confident that I am on the right
track.
Much luck and hopefully at least a bit of fun;-)
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- Implementing an interface
- From: bcpkh
- Re: Implementing an interface
- From: Jens Thoms Toerring
- Re: Implementing an interface
- From: bcpkh
- Implementing an interface
- Prev by Date: Re: Implementing an interface
- Next by Date: Re: malloc_size
- Previous by thread: Re: Implementing an interface
- Next by thread: malloc_size
- Index(es):
Relevant Pages
|