You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cliff Woolley <JW...@wlu.edu> on 2000/07/22 04:32:28 UTC

buckets: null terminated strings?

I was trying to accomplish the seemingly simple task of cleaning up a
few problems with *_insert and *_split, and keep bashing my head against
the wall for one simple reason:

Because we allow the data in a bucket to be treated as a regular string
by simply returning a pointer to the beginning of it, we assume that
that data is null-terminated somehow.  But when we split a bucket (take
an rmem or mmap bucket for example), we never shove in a null byte in
between half a and half b of the original string, so getting the string
from bucket a would return the original string (ie, a+b), not just a --
that is, not without copying b in order to do the split so that we would
have a place to stick in that extra null byte at the end of a.  YUCK!

So I guess we have to force bucket b to be created as a new rwmem bucket
(thereby copying that half of the data) in order to split it off from
bucket a?  That seems like the cleanest way to do it to me. 
Unfortunately.  What about mmap buckets?  Is it correct that splitting
an mmap bucket into two pieces should yield one mmap bucket and one
rwmem bucket?

Am I just flat out wrong, or is there some other really, really, obvious
solution that I'm not seeing, or is this pretty much just the way it is?

--Cliff

Cliff Woolley
Central Systems Software Administrator
Washington and Lee University
http://www.wlu.edu/~jwoolley/

Work: (540) 463-8089
Pager: (540) 462-2303

Re: buckets: null terminated strings?

Posted by Greg Stein <gs...@lyra.org>.
On Fri, Jul 21, 2000 at 10:32:28PM -0400, Cliff Woolley wrote:
>...
> So I guess we have to force bucket b to be created as a new rwmem bucket
> (thereby copying that half of the data) in order to split it off from
> bucket a?  That seems like the cleanest way to do it to me. 
> Unfortunately.  What about mmap buckets?  Is it correct that splitting
> an mmap bucket into two pieces should yield one mmap bucket and one
> rwmem bucket?
> 
> Am I just flat out wrong, or is there some other really, really, obvious
> solution that I'm not seeing, or is this pretty much just the way it is?

Buckets of either form (i.e. in either of the two patches) have a specific
length, which is completely distinct from where the null-termination byte
may be. In fact, there is no guarantee whatsoever that a null-term will even
exist.

If you have 10 bytes in one bucket and want to split it, then you end up
with two buckets:

1) ptr = original
   len = 5

2) ptr = original + 5
   len = 5

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: buckets: null terminated strings?

Posted by rb...@covalent.net.
The buckets are not NULL terminated strings.  The buckets each have a
different syntax.  The only thing they all have in common, is that they
all resolve to a string and a length.  Although we allow people to get
just a pointer to the start of the string, it is always assumed that
people will get the start and the length.  Some buckets won't require
this, but most will.

The big thing, is that these are NOT NULL-terminated strings.

Ryan 


On Fri, 21 Jul 2000, Cliff Woolley wrote:

> 
> I was trying to accomplish the seemingly simple task of cleaning up a
> few problems with *_insert and *_split, and keep bashing my head against
> the wall for one simple reason:
> 
> Because we allow the data in a bucket to be treated as a regular string
> by simply returning a pointer to the beginning of it, we assume that
> that data is null-terminated somehow.  But when we split a bucket (take
> an rmem or mmap bucket for example), we never shove in a null byte in
> between half a and half b of the original string, so getting the string
> from bucket a would return the original string (ie, a+b), not just a --
> that is, not without copying b in order to do the split so that we would
> have a place to stick in that extra null byte at the end of a.  YUCK!
> 
> So I guess we have to force bucket b to be created as a new rwmem bucket
> (thereby copying that half of the data) in order to split it off from
> bucket a?  That seems like the cleanest way to do it to me. 
> Unfortunately.  What about mmap buckets?  Is it correct that splitting
> an mmap bucket into two pieces should yield one mmap bucket and one
> rwmem bucket?
> 
> Am I just flat out wrong, or is there some other really, really, obvious
> solution that I'm not seeing, or is this pretty much just the way it is?
> 
> --Cliff
> 
> Cliff Woolley
> Central Systems Software Administrator
> Washington and Lee University
> http://www.wlu.edu/~jwoolley/
> 
> Work: (540) 463-8089
> Pager: (540) 462-2303
> 


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------