Re: [NEWBIE] Examine X.corpse problem.

From: Dan Merillat (harik@chaos.ao.net)
Date: 04/05/00


Juliano Ravasi Ferraz writes:
> > If your libc has it, try strdupa() rather then strdup... it's automatically
> > free()'d when your function returns, and is cheaper (cpu-wise) then malloc
> > (which strdup() uses).
> >
> > It's fairly common now, at least in unix.  (most muds are running on
> > freebie/linux systems, and they both have it.)
>
> What is your version of libc? I have GNU libc 2.1.1 and it does not have
> this func.

Hmm... alloca is common, but looks like strdupa is an extension.

you have to #define _GNU_SOURCE to use strdupa (before any #include directives)

It's the equiv of
new=alloca(strlen(old));
memcpy(new, old, strlen(old));

--Dan


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT