[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Reference counts?



Hallvard B Furuseth wrote:
Just a loose idea...

Ownership often seems a bit hairy to keep track of, like ITS#4550
just now. I've been wondering if it would ease things up to add
reference counts to some objects, but I don't know just when it
would be useful...

Well, Ando added some MUSTBEFREED flags for *rs, I guess we need one for TEXT.


Maybe berval-like constant strings instead of rs->sr_text/sr_matched,
for example:
   struct ber_rval {
       ber_len_t  bv_len;
       ber_uint_t bv_refcount; /* or maybe just "unsigned" is enough */
       const char bv_val[1];
       /* add strlen() to allocated size, terminate with \0 */
   };

Not sure how that would have prevented this particular bug. Ownership seems to be a different concept from reference counting.


--
 -- Howard Chu
 Chief Architect, Symas Corp.  http://www.symas.com
 Director, Highland Sun        http://highlandsun.com/hyc
 OpenLDAP Core Team            http://www.openldap.org/project/