bj at gmx.net
Mon Jun 3 17:50:06 UTC 2002
Sorry for not responding earlier ...
I'm not to sure by how much slower this is gonna be since the function
will be implemented inside a parser and is most frequently called.
Maybe calling strlen(dest) (as you suggest) within the function might
not even be much more overhead than updateing str_t->count, str_t->size
I will do some tests.
Thanks for the idea,
On Friday 31 May 2002 12:38, Malcolm V wrote:
> On Thu, 2002-05-30 at 04:59, Joachim Bauernberger wrote:
> > Hi,
> > I would like to implement a string object (structure) for a library
> > which I can grow dynamically.
> > I intend to use this in a situation where I don't want to worry
> > src is gonna fit into dst (str(n)cpy() problem).
> > So far I have come up with the following however I am not really
> > how efficient/useful this is.
> Why not just create a replacement function for strcpy/cat that uses
> the same method to dynamically grow your destination (dst)?
> This would have the disadvantage of having to recalculate the size of
> dst each time it is called, but it gives the advantage that in all
> cases it is simply a char pointer which you can pass off to other
> functions without being worried about having to update the values in
> rest of the structure (count and size).
> Just my thoughts,
> Malcolm V.
More information about the linuxCprogramming