[LCP]dynamic string

Malcolm V farkit at iprimus.com.au
Fri May 31 20:41:06 UTC 2002


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 whether
> src is gonna fit into dst (str(n)cpy() problem).
> So far I have come up with the following however I am not really sure 
> 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 other
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 the
rest of the structure (count and size).

Just my thoughts,
  Malcolm V.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: This is a digitally signed message part
Url : http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20020531/1ea7d620/attachment.pgp 


More information about the linuxCprogramming mailing list