[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Oops.

From: mark benedetto king <mbk_at_boredom.org>
Date: 2003-02-10 15:33:19 CET

On Sun, Feb 09, 2003 at 11:12:31PM -0600, cmpilato@collab.net wrote:
> I've noticed that our new UUIDs include a NULL character as part of
> the stored db data. Is this intentional? I don't particularly like
> it.
>

I had it without the null at first, but I thought adding it in
made the code a little cleaner because I didn't have to worry about
null-terminating the data coming *out* of the table.

I see that you've done

   *uuid = apr_pstrmemdup(trail->pool, value.data, value.size + 1);

It is my impression that BDB makes no guarantees about what the value
of the byte at value.data[value.size] is. It might not be NUL, and
I'm pretty sure I've seen it as ' '.

Anyway, because of this I went and actually *looked* at apr_pstrmemdup(),
and I'll bet the right thing to do is change this to

   *uuid = apr_pstrmemdup(trail->pool, value.data, value.size);

because apr_pstrmemdup() automatically allocates N+1 bytes and NUL-terminates.

Then we get to have our cake (not store the NULs) and eat it too (not
screw around with NUL termination).

--ben

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Feb 10 15:34:20 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.