lkml.org 
[lkml]   [2007]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4] stringbuf: A string buffer implementation
On Tue, Oct 23, 2007 at 10:19:06PM -0400, Eric St-Laurent wrote:
> I don't know if copy-on-write semantics are really useful for current
> in-kernel uses, but I've coded and used a C++ string class like this in
> the past:

CoW isn't in the slightest bit helpful. The point of these is to
provide an accumulator, therefore the majority of accesses to these
stringbufs are writes.

> Multiple string objects can share the same data, by increasing the nrefs
> count, a new data is allocated if the string is modified and nrefs > 1.

If we were trying to get rid of char * throughout the kernel, that might
make some sense; stringbufs have a more limited target though.

> Even without copy-on-write semantics and reference counting, I think
> this approach is better because it uses 1 less "object" and allocation:
>
> struct string - "handle" (pointer really) to string data
> struct string_data - string data
>
> versus:
>
> struct stringbuf *sb - pointer to string object
> struct stringbuf - string object
> char *s (member of stringbuf) - string data

I think you missed the part of the patch where I said that the stringbuf
is normally allocated on the stack or as part of some other structure.
The only thing that should be allocated is the string itself.

--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-10-24 04:37    [from the cache]
©2003-2011 Jasper Spaans