On Sun, 21 Jan 2001, Hubert Figuiere wrote:

[On the merits of strdup'ing or not]

> He can probably borrow the implementation we have in AbiWord :-)
> But this scares me as this would duplicate code. Perhaps finding a 
> way to combine both, ie use its own strdup if none is available, but 
> use UT_strdup if we compile psiconv within AbiWord :-))

I think that you are scared for no practical reason.  strdup can
even be turned into a macro composed of other standard function
calls (all of which live in the C library generally).

char * my_strdup(const char *in) {
        return strcpy(malloc(strlen(in)+1), in);
}

doesn't really add an excessive amount of bloat ... granted
it doesn't behave nice in error conditions, but you can fix
that to make it more efficient and nicer to play with in just
a couple of extra lines.

Thomas
-------------------------------------------------------------
Thomas (toe-mah) Fletcher       QNX Software Systems
[EMAIL PROTECTED]                 Neutrino Development Group
(613)-591-0931                  http://www.qnx.com/~thomasf


Reply via email to