This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: use of malloc


On Fri, Apr 21, Ulrich Drepper wrote:


> - make sure you free all the memory allocated in the error case.  This
>   might get ugly but, as in the NIS file I corrected, you can use goto
>   for this.  This is a legitemate use of goto.

Uli, please look at the ChangeLog file. You have removed similar free's
in other parts of the NIS code.


> - optimize the user of malloc/calloc.  Often a struct and its content
>   have to be allocated at the same time.  The easiest way if to do it
>   on two steps with two allocations.  But if the information has the
>   same lifetime this is a waste.  The malloc and especially the free
>   function is pretty slow.

This is not true for NIS. All NIS functions needs the most time waiting
for the network. You will not see your optiomization in any benchmark,
but it makes the code look more ugly.

And your new Code is wrong. You derefence NULL Pointer !!!!!
Please remove it complete and don't change code, which you don't
understand in such a way.
What do you think is xdr_free () good for ?

  Thorsten

-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/       kukuk@suse.de
SuSE GmbH            Schanzaeckerstr. 10            90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]