[LCP]dynamic string
David Filion
filiond at videotron.cq
Wed Jul 3 17:15:20 UTC 2002
On May 29, 2002 02:59 pm, you 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.
<code snipped>
> I have implemented xmalloc to terminate the program with an error
> message in case malloc fails. Since I can't think of any situation
> where I would want to carry on in this case, can you?
>
> Any thoughts on doing things differently?
>
> Thanks & Best regards,
> /joachim
>
> PS:
> Sorry for all that code but thought it'd be better than trying to
> describe what I want to achieve ....
GLib has a dynamic string "class". If you want some hints, take a
look at its code. It might give you some ideas.
David
More information about the linuxCprogramming
mailing list