geoff@desint.UUCP (Geoff Kuenning) (01/27/85)
There are a couple of small problems with the latest posting of pathalias: (1) The commentary in the makefile neglects to mention that the program uses 'index' and 'rindex'. USG sites should add -Dindex=strchr and -Drindex=strrchr to their CFLAGS. (2) The commentary in the config.h file is misleading about the MYMALLOC routine. If you examine the private malloc, you will discover that its speed is based on the fact that the private free is a no-op. This is fine for virtual systems, but sites with limited memory should be aware that using MYMALLOC may cause pathalias to run out of memory. (3) Once you have undefined MYMALLOC, pathalias will begin to core dump, because it calls free several times with the same argument. The fix is ridiculously simple, and is given below (note: these are hand- built context diffs, so if 'patch' has trouble add the line by hand): Index: pathalias.c *** pathalias.c.orig Sat Jan 26 01:34:22 PST 1985 --- pathalias.c Sat Jan 26 16:47:34 PST 1985 *************** *** 88,93 } /* merge child links into parent (now root) */ parent->n_link = lmerge(parent->n_link, child->n_link); /* set up the alias pointers */ --- 88,94 ----- } /* merge child links into parent (now root) */ parent->n_link = lmerge(parent->n_link, child->n_link); + child->n_link = 0; /* set up the alias pointers */ -- Geoff Kuenning Unix Consultant ...!ihnp4!trwrb!desint!geoff
honey@down.FUN (code 101) (01/28/85)
Re (1), USG and index/rindex/strchr/strrchr: if you define ATTSV in config.h, def.h will define index and rindex for you. Re (2), MYMALLOC commentary: Geoff oversimplifies. It's true that myfree() is a no-op, but observe that mymalloc() uses a buffered sbrk() scheme. I did a lot of profiling, against every version of malloc I could find and discovered that mymalloc() wins on time *and* space. It's easy to see why it wins on time. For space, I found that almost all of the free()-ing comes after almost all of the malloc()-ing, thus very little space is re-used, so you never win back the space overhead. Re (3), core dump if you don't use mymalloc(): thank you, I'll look at this right away. Peter
greg@ncr-tp.UUCP (Greg Noel) (01/30/85)
In article <328@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes: >There are a couple of small problems with the latest posting of pathalias: > > (1) The commentary in the makefile neglects to mention that the program > uses 'index' and 'rindex'. USG sites should add -Dindex=strchr and > -Drindex=strrchr to their CFLAGS. > Well, almost. It turns out that this substitution is done automaticly in def.h but one file that uses index() does not #include it. The offending file is gethostnam.c, and an examinination of it reveals that this code will ALWAYS be present, despite the #ifndef that tries to prevent it, so that the library version of gethostname() will NEVER be used. Further perusal shows that gethostname() is only required if neither GETHOSTNAME nor UNAME is #defined; a site that had uname() but not gethostname() might set up config.h to indicate this condition, and would needlessly include the routine, so this should be tested as well. The diff for this is attached below. BTW, the diff in the referenced article should be applied to addnode.c, not pathalias.c as it indicates. *** gethostnam.orig Tue Jan 29 17:23:07 1985 --- gethostnam.c Tue Jan 29 15:36:10 1985 *************** *** 2,7 static char *sccsid = "@(#)gethostnam.c 6.1 (down!honey) 85/01/21"; #endif lint #ifndef GETHOSTNAME #include <stdio.h> --- 2,9 ----- static char *sccsid = "@(#)gethostnam.c 6.1 (down!honey) 85/01/21"; #endif lint + #include "def.h" + #ifndef UNAME #ifndef GETHOSTNAME void *************** *** 3,9 #endif lint #ifndef GETHOSTNAME - #include <stdio.h> void gethostname(name, len) --- 5,10 ----- #include "def.h" #ifndef UNAME #ifndef GETHOSTNAME void gethostname(name, len) *************** *** 53,55 return; } #endif GETHOSTNAME --- 54,57 ----- return; } #endif GETHOSTNAME + #endif UNAME -- -- Greg Noel, NCR Torrey Pines Greg@ncr-tp.UUCP or Greg@nosc.ARPA