Re: gobject api help



Hi,

On Thu, Apr 3, 2008 at 1:34 PM, D Bera <dbera web gmail com> wrote:
> For those who deal with gobject API, when you pass a string (char* or
>  const char*) to an API function, whose responsibility is it to free
>  the string ? What is the usual practice ? Is there any way to
>  distinguish methods that take a string and "own" it and methods that
>  make a copy of the string so the caller can safely free it or reassign
>  it to something else ?

The general policy is that strings are always copied when passed as an
argument, and they should always be declared "const char *".  That way
neither side needs to know how the memory of the argument was
allocated.

As to your distinguishing question, the answer is no, but it shouldn't
really come up anyhow.

Joe


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