httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeffrey A. Stuart" <>
Subject RE: counted strings (was: Re: SGI Patch 10xpatch-2.0a6-5 - eliminate use of sprintf() to format inet_ntoa conversions)
Date Sat, 24 Feb 2001 03:10:28 GMT
Without even reviewing it so far, this sounds like it makes sense. :)  While
not a normal coder or even a reviewer yet here's a +1 if it's needed...
(Hmm... me wonders if I might want to borrow this idea... Hmm... :))

Jeff (FurBall)
WebOverdrive Newbie Tech Board

-----Original Message-----
From: Greg Stein []
Sent: Friday, February 23, 2001 8:24 PM
Subject: counted strings (was: Re: SGI Patch 10xpatch-2.0a6-5 - eliminate
use of sprintf() to format inet_ntoa conversions)

On Fri, Feb 23, 2001 at 04:45:52PM -0800, wrote:
> On Fri, 23 Feb 2001, Jim Jagielski wrote:
> > Greg Stein wrote:
> > >
> > > In the future, if we want to optimize away strlen() calls, then we
> > > introduced a "counted string" type. Subversion has one, along with a
> > > of support functions, which is APR pool-aware. We could snarf those if
> > > chose. [and place them into APRUTIL]
> > >
> >
> > Hows the performance? Does it provide too much overheard for
> > it to be a generic solution? But I'm +1 for this addition.

Performance? Not a problem. They're visible structures:

/* The svn_string_t data type.  Pretty much what you expected. */
typedef struct svn_string_t
  char *data;                /* pointer to the bytestring */
  apr_size_t len;            /* length of bytestring */
  apr_size_t blocksize;      /* total size of buffer allocated */
  /* pool from which this string was originally allocated, and is not
     necessarily specific to this string.  This is used only for
     allocating more memory from when the string needs to grow.  */
  apr_pool_t *pool;
} svn_string_t;

We pass around "svn_string_t *" values. Accessing the data is simply
str->data. The string is guaranteed to be null-terminated, which simplifies
interop with OS functions. It is also counted, so things like memcpy() can
be used. (the null-term is not counted in "len")

Since it is counted, it is also useful for binary data.

> I'm +1 for it too.  I would put it directly into APR though.  Two string
> types, counted and regular.  But that's just an opinion.

Actually, a good one. I said APRUTIL simply because it's totally portable.
But APR itself would want to use this datatype, I'm sure.

That is two +1 votes, and a +1 from me. I've attached the header for review.


Greg Stein,

View raw message