Currently we often do a octstr_duplicate instead of the
octstr_get_ref in my made up example. This is simplified 
but the pattern occurs quite often...

Regards
  Jörg

-----Original Message-----
From: Aarno Syvänen
To: Jörg Pommnitz
Cc: ''[EMAIL PROTECTED]' '
Sent: 12/12/01 11:37 AM
Subject: Re: Ref-Counted octstr

Hi,

Jörg Pommnitz wrote:
> 
> I'm not sure I completely understand you. What I'd like
> to allow would be something like this:
> 
>   Octstr *foo;
>   Octstr *bar;
> 
>   if (condition (bar)) {
>     foo = do_something_with (bar); /* foo points to a new Octstr,
refcount =
> 1 */
>   } else {
>     foo = octstr_get_ref (bar);    /* foo becomes a new reference to
the
> Octstr
>                                       pointed to by bar; refcount = 2
*/
>   }
> 
>   do_something_else (foo);
> 
>   octstr_destroy (foo);            /* refcount gets decremented. if it
> reaches zero,
>                                       the Octstr actually gets
released */

Huh. What did you mean with "unneeded octstr_duplicate calls" ?

Aarno

Reply via email to