Re: cvs commit: squid/src MemBuf.c

From: Alex Rousskov <>
Date: Thu, 18 Apr 2002 07:56:48 -0600 (MDT)

On Thu, 18 Apr 2002, Andrew Bartlett wrote:

> > Yes, having both terminated buf.c_str() and raw is a good
> > approach.
> But if it is really RAW memory, there is a very good chance its got
> nulls in it.

That's OK. Null-terminating raw memory that already has nulls is safe
(though probably useless). Whoever calls buf.c_str() on such a buffer
probably does not know what they are doing, but they will get what the
interface promises.

This is a pretty standard approach used, among other places, in STL
string class.

> In samba we have a dump_data() procedure that takes a pointer and
> a length, and produces a hex-editor like dump of the data.

Yes, if somebody wants to print a piece of raw data, they should not
use buf.c_str(), they should use something like
        printRaw(, buf.size())
where printRaw does appropriate escaping of non-printable characters.

Received on Thu Apr 18 2002 - 07:58:21 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:12 MST