savestring()
Andrew Cagney
ac131313@cygnus.com
Wed Mar 21 15:59:00 GMT 2001
"J.T. Conklin" wrote:
>
> Lint complaints about signed/unsigned conversions in the typical use
> of savestring:
ARI just complains about it :-)
> x->foo = savestring(bar, strlen(bar));
>
> Is there any reason why we shouldn't change the type of savestring's
> (likewise msavestring) second argument from int to size_t?
>
> Also, since the above is the same as:
>
> x->foo = xstrdup(bar);
>
> Is there any reason why we shouldn't change it? It's a bit odd that
> half the code uses savestring() and the other half uses xstrdup().
>From the TODO file.
--
Replace savestring() with something from libiberty.
An xstrldup()? but that would have different semantics.
--
There may be more on this in the GDB and OpenBSD e-mail archives. I
sent an e-mail to the OpenBSD group asking if there should be a
strldup() like function - the strl*() functions originated from someone
in OpenBSD land.
Anyway, yes, some instances of savestring should be xstrdup() but others
are not so should probably get ``X'' rated treatment :-)
As for size_t. I have no idea, does libiberty manage to use size_t in
its headers? If it does then, why not :-)
Andrew
More information about the Gdb
mailing list