diff -u -r zmailer-2.99.49/ChangeLog zmailer-2.99.49p1/ChangeLog --- zmailer-2.99.49/ChangeLog Sun Jun 15 19:45:43 1997 +++ zmailer-2.99.49p1/ChangeLog Thu Jun 19 19:50:30 1997 @@ -1,3 +1,30 @@ +Thu Jun 19 19:41:47 1997 Matti Aarnio + + * Makefile.in + Version 2.99.49p1 + + * configure.in: + Reordered (and changed default) of --with-libmalloc= + option parameters + + * lib/selfaddrs.c: + Detected that SunSoft SunPro C 3.0 didn't define + '__svr4__', but does '__SVR4' -- automatic Solaris + support failed due to that.. + + * libsh/listmalloc.c: + Debugged, and got it finally working.. (something for + Zmailer 3.0 ...) + + * smtpserver/smtpcmds.c: + Freed memory blocks that were not malloc()ed at all.. + + * transports/libta/diagnostics.c: + 'notarybuf' can be a NULL pointer, prepare for it! + + * utils/makendbm/makendbm.c: + Just some casts to please SunOS 4.1.x compilation + Fri Jun 13 22:41:04 1997 Matti Aarnio * Makefile.in: diff -u -r zmailer-2.99.49/Makefile.in zmailer-2.99.49p1/Makefile.in --- zmailer-2.99.49/Makefile.in Sun Jun 15 03:32:15 1997 +++ zmailer-2.99.49p1/Makefile.in Thu Jun 19 19:50:37 1997 @@ -2,7 +2,7 @@ MAJORVERSION = 2 MINORVERSION = 99 -PATCHLEVEL = 49 +PATCHLEVEL = 49p1 srcdir = @srcdir@ VPATH = @srcdir@ diff -u -r zmailer-2.99.49/configure.in zmailer-2.99.49p1/configure.in --- zmailer-2.99.49/configure.in Sun Jun 15 02:19:53 1997 +++ zmailer-2.99.49p1/configure.in Thu Jun 19 10:25:55 1997 @@ -235,22 +235,22 @@ use_system_malloc=1) AC_ARG_WITH(libmalloc, [ --with-libmalloc=LIBNAME define the name of the malloc library - possible values: system, malloc_d, malloc (default)], + possible values: malloc, malloc_d, system (default)], use_libmalloc=1) if test "x$use_system_malloc" = x1 ; then LIBMALLOC="" MALLOC="system" else - if test "x$withval" = xsystem ; then - LIBMALLOC="" - MALLOC="system" + if test "x$withval" = xmalloc_d -o "x$withval" = xmalloc ; then + LIBMALLOC="-l$withval" + MALLOC="$withval" + if text "$withval" = "malloc_d" ; then + MALLOCEXT="_d" + fi else - if test "x$withval" = xmalloc_d -o "x$withval" = xmalloc ; then - LIBMALLOC="-l$withval" - MALLOC="$withval" - if text "$withval" = "malloc_d" ; then - MALLOCEXT="_d" - fi + if test "x$withval" = xsystem -o "x$use_libmalloc" != x1; then + LIBMALLOC=""; MALLOCEXT="" + MALLOC="system" else eval LIBMALLOC="-l${MALLOC-malloc}" if test "x$LIBMALLOC" = "x-lmalloc_d"; then diff -u -r zmailer-2.99.49/doc/manual/content.txt zmailer-2.99.49p1/doc/manual/content.txt --- zmailer-2.99.49/doc/manual/content.txt Wed Jun 11 18:35:58 1997 +++ zmailer-2.99.49p1/doc/manual/content.txt Mon Jun 16 14:59:45 1997 @@ -7,6 +7,7 @@ 1. Introduction to Email 2. ZMailer's features and facilities 3. Running Zmailer (short) + 4. Comparison with other popular MTAs II Build and Install ( 20 ) diff -u -r zmailer-2.99.49/include/listutils.h zmailer-2.99.49p1/include/listutils.h --- zmailer-2.99.49/include/listutils.h Mon May 12 01:32:34 1997 +++ zmailer-2.99.49p1/include/listutils.h Tue Jun 17 09:57:35 1997 @@ -116,7 +116,7 @@ /* LISPic memory allocator, and other stuff.. */ extern int cons_garbage_collect __((void)); extern int consvar_register __(( const conscell* )); -extern void *consvar_mark __(( void * )); +extern void *consvar_mark __(( void )); extern void consvar_release __(( void* )); #endif /* _LISTUTILS_H */ diff -u -r zmailer-2.99.49/lib/selfaddrs.c zmailer-2.99.49p1/lib/selfaddrs.c --- zmailer-2.99.49/lib/selfaddrs.c Fri May 23 01:17:14 1997 +++ zmailer-2.99.49p1/lib/selfaddrs.c Thu Jun 19 10:49:10 1997 @@ -32,7 +32,7 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif -#if defined(__svr4__) && defined(__sun) +#if (defined(__svr4__) || defined(__SVR4)) && defined(__sun) # define BSD_COMP /* Damn Solaris, and its tricks... */ #endif #include diff -u -r zmailer-2.99.49/libsh/Makefile.in zmailer-2.99.49p1/libsh/Makefile.in --- zmailer-2.99.49/libsh/Makefile.in Mon May 12 00:54:16 1997 +++ zmailer-2.99.49p1/libsh/Makefile.in Tue Jun 17 10:05:03 1997 @@ -35,6 +35,10 @@ # keeping zmsh.o after the library is important due to the 'rm -f *.o' below... $(PROGRAM)-a: $(LIBDEB) $(PROGRAM) +listmalloc: listmalloc.c + $(CC) -S $(CFLAGS) -DDEBUG -o listmalloc.s listmalloc.c + $(CC) $(CFLAGS) -o listmalloc listmalloc.s + $(PROGRAM): $(TOPDIR)/libs/$(LIBNAME).a version.o $(LIBDEB) $(CC) $(CFLAGS) -o $@ main.o version.o $(LIB) $(ZSH_LIB) diff -u -r zmailer-2.99.49/libsh/listmalloc.c zmailer-2.99.49p1/libsh/listmalloc.c --- zmailer-2.99.49/libsh/listmalloc.c Sat May 10 14:29:29 1997 +++ zmailer-2.99.49p1/libsh/listmalloc.c Thu Jun 19 19:58:39 1997 @@ -10,6 +10,10 @@ #include "hostenv.h" #include "listutils.h" +#ifndef __GNUC__x +#define __inline__ /* nothing for non-GCC */ +#endif + /* * We allocate conscells in set of blocks, where we do garbage collections * at every N requests, or other trigger criteria.. @@ -19,161 +23,221 @@ * from which they are picked into use. */ typedef struct consblock { - struct consblock *nextblock; - int cellcount; - conscell cells[1]; /* Array of ``cellcount'' cells */ + struct consblock *nextblock; + int cellcount; +#ifdef __alpha /* Align the conscells by cache-line.. */ + void *dummy1; + void *dummy2; +#endif + conscell cells[1]; /* Array of ``cellcount'' cells */ } consblock; +#ifndef NO_CONSVARS /* * Variable pointers -- arrays of pointers to conscells */ typedef struct consvarptrs { - struct consvarptrs *nextvars; - int count; /* large (?) sets of vars */ - int first; /* this block has vars of indices - ``first .. first+count-1'' */ - const conscell *vars[1]; /* Address of an variable */ + struct consvarptrs *nextvars; + int count; /* large (?) sets of vars */ + int first; /* this block has vars of indices + ``first .. first+count-1'' */ + const conscell *vars[1]; /* Address of an variable */ } consvarptrs; +#endif + + +#define NSTATICVARS 16 /* SHOULD be enough for ZMailer... */ +static conscell **staticvec[NSTATICVARS] = { NULL }; +static int staticidx = 0; + +static void (*functionvec[NSTATICVARS])() = { NULL }; +static int functionidx = 0; + +/* Put an entry in staticvec, pointing at the variable + whose address is given */ + +void staticpro (varaddress) +conscell **varaddress; +{ + staticvec[staticidx++] = varaddress; + if (staticidx >= NSTATICVARS) + abort (); /* TOO MANY! Should need only very few.. */ +} + +void functionpro (funcaddress) +void (*funcaddress) __((conscell *)); +{ + functionvec[functionidx++] = funcaddress; + if (functionidx >= NSTATICVARS) + abort(); /* TOO MANY! Should need only very few.. */ +} + /* * Some book-keeping variables, and one of GC-trigger counters */ -int consblock_cellcount = 1000; /* Optimizable for different systems. - Alphas have 8kB pages, and most others - have 4kB pages.. */ -int newcell_gc_interval = 1000; /* Number of newcell() calls before GC */ -int newcell_gc_callcount = 0; /* ... trigger-count of those calls ... */ -int newcell_callcount = 0; /* ... cumulative count of those calls ... */ - -consblock *consblock_root = NULL; -consblock *consblock_tail = NULL; -conscell *conscell_freechain = NULL; /* pick first .. */ -int consblock_count = 0; /* How many allocated ? */ - -int consvars_cellcount = 4000; -consvarptrs *consvars_root = NULL; -consvarptrs *consvars_tail = NULL; -int consvars_cursor = 0; /* How many variables are in use ? - Actually NOT direct pointer, and - the user might have to traverse - the chains a bit at first.. */ -consvarptrs *consvars_markptr = NULL; /* For speedier insert */ -int consvars_count = 0; /* Allocation count */ - -static consblock * new_consblock __((void)); -static consblock * new_consblock() -{ - consblock *new; - int i; - int newsize = (sizeof(consblock) + - sizeof(conscell) * (consblock_cellcount-1)); - - new = (consblock *)malloc(newsize); - if (!new) return NULL; - - new->cellcount = consblock_cellcount; - new->nextblock = NULL; - if (consblock_root == NULL) - consblock_root = new; - else - consblock_tail->nextblock = new; - consblock_tail = new; +int consblock_cellcount = 1000; /* Optimizable for different systems. + Alphas have 8kB pages, and most others + have 4kB pages.. */ +int newcell_gc_interval = 1000; /* Number of newcell() calls before GC */ +int newcell_gc_callcount = 0; /* ... trigger-count of those calls ... */ +int newcell_callcount = 0; /* ... cumulative count of those calls ... */ + +consblock *consblock_root = NULL; +consblock *consblock_tail = NULL; +conscell *conscell_freechain = NULL; /* pick first .. */ +int consblock_count = 0; /* How many allocated ? */ + +struct gcpro *gcprolist = NULL; /* Dynamically growing list of protected + items.. */ +#ifndef NO_CONSVARS +int consvars_cellcount = 4000; +consvarptrs *consvars_root = NULL; +consvarptrs *consvars_tail = NULL; +int consvars_cursor = 0; /* How many variables are in use ? + Actually NOT direct pointer, and + the user might have to traverse + the chains a bit at first.. */ +consvarptrs *consvars_markptr = NULL; /* For speedier insert */ +int consvars_count = 0; /* Allocation count */ +#endif - /* chain them together, and prepend to the free chain via ``next'' */ - new->cells[0].next = conscell_freechain; - new->cells[0].flags = 0; - for (i = 1; i < consblock_cellcount; ++i) { - new->cells[i].next = &new->cells[i-1]; - new->cells[i].flags = 0; - } - conscell_freechain = &new->cells[consblock_cellcount-1]; +static consblock *new_consblock __((void)); +static consblock *new_consblock() +{ + consblock *new; + int i; + int newsize = (sizeof(consblock) + + sizeof(conscell) * (consblock_cellcount - 1)); + +#ifdef DEBUG + printf("new_consblock(%d cells)\n", consblock_cellcount); +#endif + + new = (consblock *) malloc(newsize); + if (!new) + return NULL; + + memset(new, 0, newsize); /* Sigh.. */ + + new->cellcount = consblock_cellcount; + new->nextblock = NULL; + if (consblock_root == NULL) + consblock_root = new; + else + consblock_tail->nextblock = new; + consblock_tail = new; + + /* chain them together, and prepend to the free chain via ``next'' */ + new->cells[0].next = conscell_freechain; + new->cells[0].flags = 0; + for (i = 1; i < consblock_cellcount; ++i) { + new->cells[i].next = &new->cells[i - 1]; + new->cells[i].flags = 0; + } + conscell_freechain = &new->cells[consblock_cellcount - 1]; - ++consblock_count; - return new; + ++consblock_count; + return new; } +#ifndef NO_CONSVARS static consvarptrs *new_consvars __((int)); static consvarptrs *new_consvars(first) - int first; +int first; { - consvarptrs *new; - int newsize = (sizeof(consvarptrs) + - sizeof(conscell *) * (consvars_cellcount-1)); - - new = (consvarptrs *) malloc(newsize); - if (!new) return NULL; - - new->first = first; - new->count = consvars_cellcount; - new->nextvars = NULL; - if (consvars_root == NULL) { - consvars_root = new; - consvars_markptr = new; - } else - consvars_tail->nextvars = new; - consvars_tail = new; - ++consvars_count; - return new; + consvarptrs *new; + int newsize = (sizeof(consvarptrs) + + sizeof(conscell *) * (consvars_cellcount - 1)); + +#ifdef DEBUG + printf("new_consvars(first=%d; %d varcells)\n", first, consvars_cellcount); +#endif + + new = (consvarptrs *) malloc(newsize); + if (!new) + return NULL; + + new->first = first; + new->count = consvars_cellcount; + new->nextvars = NULL; + if (consvars_root == NULL) { + consvars_root = new; + consvars_markptr = new; + } else + consvars_tail->nextvars = new; + consvars_tail = new; + ++consvars_count; + return new; } void *consvar_mark() { - return (void*)consvars_cursor; +#ifdef DEBUG + printf ("consvar_marker() returns 0x%p\n", (void*)consvars_cursor); +#endif + return (void *) consvars_cursor; } void consvar_release(marker) void *marker; { - int newmark = (int) marker; + int newmark = (int) marker; - if (newmark > consvars_cursor) { - abort(); /* XX: Something seriously wrong, release INCREASED - the count of variables! */ - } - consvars_cursor = newmark; - --newmark; /* change into index -- from counter (sort of) */ - - if (consvars_markptr == NULL) return; /* no cells ? */ - - if ((consvars_markptr->first <= newmark) && - (newmark < (consvars_markptr->first + consvars_markptr->count))) - return; /* The markptr is ok */ - - /* Lookup for the block marker */ - consvars_markptr = consvars_root; - while (newmark < consvars_markptr->first) { - consvars_markptr = consvars_markptr -> nextvars; - } + if (newmark > consvars_cursor) { + abort(); /* XX: Something seriously wrong, release INCREASED + the count of variables! */ + } + consvars_cursor = newmark; + --newmark; /* change into index -- from counter (sort of) */ + + if (consvars_markptr == NULL) + return; /* no cells ? */ + + if ((consvars_markptr->first <= newmark) && + (newmark < (consvars_markptr->first + consvars_markptr->count))) + return; /* The markptr is ok */ + + /* Lookup for the block marker */ + consvars_markptr = consvars_root; + while (newmark < consvars_markptr->first) { + consvars_markptr = consvars_markptr->nextvars; + } } + /* ConsCell variable pointer registry */ int consvar_register(varptr) const conscell *varptr; { - int marklast, idx; + int marklast, idx; - if (consvars_root == NULL) { - if (new_consvars(0) == NULL) - return -1; - consvars_cursor = 0; - } +#ifdef DEBUG + printf("consvar_register(varptr=0x%p)\n", varptr); +#endif - marklast = (consvars_markptr -> first + - consvars_markptr -> count); - ++consvars_cursor; - if (marklast <= consvars_cursor) { - if (consvars_markptr->nextvars == NULL) - consvars_markptr = new_consvars(marklast /* the previous last is - the next first.. */ ); - else + if (consvars_root == NULL) { + if (new_consvars(0) == NULL) + return -1; + consvars_cursor = 0; + } + marklast = (consvars_markptr->first + + consvars_markptr->count); + ++consvars_cursor; + if (marklast <= consvars_cursor) { + if (consvars_markptr->nextvars == NULL) + consvars_markptr = new_consvars(marklast /* the previous last is + the next first.. */ ); + else consvars_markptr = consvars_markptr->nextvars; - if (consvars_markptr == NULL) + if (consvars_markptr == NULL) return -1; - } - idx = (consvars_cursor -1) - consvars_markptr->first; - consvars_markptr->vars[idx] = varptr; - return 0; /* Stored ok.. */ + } + idx = (consvars_cursor - 1) - consvars_markptr->first; + consvars_markptr->vars[idx] = varptr; + return 0; /* Stored ok.. */ } +#endif /* * Deutch-Schorr-Waite garbage collection routine of the conscells.. @@ -184,128 +248,219 @@ #define DSW_MASK (DSW_MARKER | DSW_BACKPTR) #define DSW_BLOCKLEFT(cptr) \ - ((cptr)->flags & ~DSW_MASK) + (((cptr)->flags & ~DSW_MASK) || ((cptr)->dtpr == NULL)) + #define DSW_BLOCKRIGHT(cptr) \ ((cptr)->next == NULL) #define DSW_BLOCK(cptr) \ (((cptr)->flags & DSW_MARKER) || \ (DSW_BLOCKLEFT(cptr) && DSW_BLOCKRIGHT(cptr))) -static void cons_DSW_rotate(pp1,pp2,pp3) +/*static*/ void cons_DSW_rotate(pp1, pp2, pp3) conscell **pp1, **pp2, **pp3; { - conscell *t; + conscell *t1, *t2, *t3; + +#ifdef DEBUG + printf("cons_DSW_rotate(0x%x, 0x%x, 0x%x)\n", pp1, pp2, pp3); +#endif + + + t1 = *pp1; + t2 = *pp2; + t3 = *pp3; + *pp1 = t2; + *pp2 = t3; + *pp3 = t1; +} - t = *pp1; - *pp1 = *pp2; - *pp2 = *pp3; - *pp3 = t; -} - -static void cons_DSW(source) -conscell *cource; -{ - conscell *current, *prev; - int state; - - current = source->next; - prev = source; - /* source->flags.back = 'next' -- current backptr value */ - source->flags &= ~DSW_BACKPTR; - source->flags |= DSW_MARKER; - - state = 1; - while (state != 0) { - switch(state) { - case 1: - /* Mark in every case */ - current->flags |= DSW_MARKER; +/*static*/ void cons_DSW(source) +conscell *source; +{ + conscell *current, *prev; + int state; + +#if 0 +#ifdef DEBUG + printf("cons_DSW(source=0x%x)\n", (void*)source); +#endif +#endif + + + if(source == NULL) + return; + if(source->next == NULL) + return; + + current = source->next; + prev = source; + /* source->flags.back = 'next' -- current backptr value */ + source->flags &= ~DSW_BACKPTR; /* Source back == right */ + source->next = source; /* !! */ + source->flags |= DSW_MARKER; + + + state = 1; + while (state != 0) { + switch (state) { + case 1: + if(DEBUG) + printf("DEBUG: 1: "); + /* Mark in every case + current->flags |= DSW_MARKER; */ /* Try to advance */ if (DSW_BLOCK(current)) { - /* Prepare to retreat */ - state = 2; + /* Prepare to retreat */ + current->flags |= DSW_MARKER; + state = 2; + printf("prepare to retreat\n"); + + if(DEBUG) { + printf("%d ", DSW_BLOCKLEFT(current)); + printf("%d ", DSW_BLOCKRIGHT(current)); + printf("%d\n", DSW_BLOCK(current)); + } } else { - /* Advance */ - if (DSW_BLOCKLEFT(current)) { - /* Follow right (next) pointer */ - current->flags &= ~DSW_BACKPTR; - cons_DSW_rotate(&prev, ¤t, ¤t->next); - } else { - /* Follow left (dptr) pointer */ - current->flags |= DSW_BACKPTR; - cons_DSW_rotate(&prev, ¤t, ¤t->dptr); - } + /* Advance */ + current->flags |= DSW_MARKER; + if (DSW_BLOCKLEFT(current)) { + if(DEBUG) + printf("adv. right\n"); + /* Follow right (next) pointer */ + current->flags &= ~DSW_BACKPTR; /* back == right */ + cons_DSW_rotate(&prev, ¤t, ¤t->next); + } else { + if(DEBUG) + printf("adv. left\n"); + /* Follow left (dtpr) pointer */ + current->flags |= DSW_BACKPTR; /* back == lext */ + cons_DSW_rotate(&prev, ¤t, ¤t->dtpr); + } } break; - case 2: + case 2: + printf("DEBUG: 2: "); /* Finish, retreat or switch */ - if (prev == current) - /* Finish */ - state = 0; - else { - if (prev->flags & DSW_BACKPTR /* Non-zero == 'dptr' */) { - if (!DSW_BLOCKRIGHT(prev)) { - prev->flags &= ~DSW_BACKPTR; - cons_DSW_rotate(&prev->dptr,¤t,&prev->next); - state = 1; - } else { - cons_DSW_rotate(&prev,&prev->dptr,¤t); - } - } else { - cons_DSW_rotate(&prev,&prev->next,¤t); + if (current == prev) { + /* Finish */ + state = 0; + if(DEBUG) + printf("finish\n"); + } + else if ((prev->flags & DSW_BACKPTR) /* prev.back == L */ + && (!DSW_BLOCKRIGHT(prev))) { + /* Switch */ + if(DEBUG) + printf("switch\n"); + prev->flags &= ~DSW_BACKPTR; /* prev.back = R */ + cons_DSW_rotate(&prev->dtpr, ¤t, &prev->next); + state = 1; + } else if (!(prev->flags & DSW_BACKPTR)) { /* prev.back == R*/ + /* Retreat */ + if(DEBUG) + printf("retreat R\n"); + cons_DSW_rotate(&prev, &prev->next, ¤t); + } + else { /* prev.back == L */ + if(DEBUG) + printf("retreat L\n"); + cons_DSW_rotate(&prev, &prev->dtpr, ¤t); } break; - default: + default: break; - } } + } } int cons_garbage_collect() { - int i, freecnt; - consblock *cb = consblock_root; - consvarptrs *vb = consvars_root; - conscell *cc; - - if (cb == NULL) return 0; /* Nothing to do! */ - - /* Start by clearing all DSW_MARKER bits */ - for ( ; cb != NULL; cb = cb->nextblock) { - cc = cb->cells; - for (i = 0; i < cb->cellcount; ++i, ++cc) + int i, freecnt; + consblock *cb = NULL; + conscell *cc; + struct gcpro *gcp = gcprolist; +#ifndef NO_CONSVARS + int cursor; + consvarptrs *vb = NULL; +#endif + + + if (consblock_root == NULL) + return 0; /* Nothing to do! */ + + /* Start by clearing all DSW_MARKER bits */ + for (cb = consblock_root; cb != NULL; cb = cb->nextblock) { + cc = cb->cells; + for (i = 0; i < cb->cellcount; ++i, ++cc) +#if 0 /* Turn on for 'Purify' testing... */ + if (cc->flags & (DSW_MARKER|DSW_BACKPTR)) +#endif cc->flags &= ~(DSW_MARKER|DSW_BACKPTR); - } - /* Hookay... Now we run marking on all cells that are - reachable from some (any) of our registered variables */ - for ( ; vb != NULL; vb = vb->nextvars) { - for (i = 0; i < vb->count; ++i) - cons_DSW(vb->vars[i]); - } - /* All are marked.. now we can scan all non-marked, and declare - them to belong into free.. Oh yes, all ISNEW(cellptr) cells - will do free(cellptr->string) */ - conscell_freechain = NULL; - freecnt = 0; - for ( ; cb != NULL; cb = cb->nextblock) { - cc = cb->cells; - for (i = 0; i < cb->cellcount; ++i) + } + + /* Hookay... Now we run marking on all cells that are + reachable from some (any) of our registered variables */ + /* Static variables */ + for (i = 0; i < staticidx; ++i) + if (*staticvec[i] != NULL) + cons_DSW(*staticvec[i]); + /* Function-format iterators */ + for (i = 0; i < functionidx; ++i) + if (*functionvec[i] != NULL) + functionvec[i](cons_DSW); + + /* Dynamically inserted (and removed) GCPROx() -variables */ + while (gcp) { + for (i= 0; i < gcp->nvars; ++i) + cons_DSW(gcp->var[i]); + gcp = gcp->next; + } + +#ifndef NO_CONSVARS + cursor = 0; + for (vb = consvars_root; vb != NULL; vb = vb->nextvars) { + for (i = 0; i < vb->count; ++i,++cursor) { + if (cursor < consvars_cursor) { + if (vb->vars[i] != NULL) + cons_DSW(*(vb->vars[i])); + } else + break; + } + } +#endif + + + /* All are marked.. now we can scan all non-marked, and declare + them to belong into free.. Oh yes, all ISNEW(cellptr) cells + will do free(cellptr->string) */ + + conscell_freechain = NULL; + freecnt = 0; + for (; cb != NULL; cb = cb->nextblock) { + cc = cb->cells; + for (i = 0; i < cb->cellcount; ++i) if (cc->flags & DSW_MARKER) { - /* It was reachable, just clean the marker bit(s) */ - cc->flags &= ~(DSW_MARKER|DSW_BACKPTR); + + /* It was reachable, just clean the marker bit(s) */ + + cc->flags &= ~(DSW_MARKER | DSW_BACKPTR); + } else { - /* This was not reachable, no marker.. */ - if (cc->flags & NEWSTRING) - free(cc->string); - cc->flags = 0; - /* this resulting list is ``reversed'' in memory order, - however that should not cause any trouble anyway.. */ - cc->next = conscell_freechain; - conscell_freechain = cc; - ++freecnt; + + /* This was not reachable, no marker was added.. */ + if (ISNEW(cc)) /* if (cc->flags & NEWSTRING) */ + free(cc->string); + cc->flags = 0; + + /* this resulting list is ``reversed'' in memory order, + however that should not cause any trouble anyway.. */ + + cc->next = conscell_freechain; + conscell_freechain = cc; + ++freecnt; } - } - return freecnt; + } + return freecnt; } @@ -314,29 +469,71 @@ * Actual heart of this all: Allocate the conscell! */ conscell * -newcell() + newcell() { - conscell *new; + conscell *new; + + /* At first, see if we are to do some GC ... */ + +#ifdef DEBUG + printf("newcell() called\n"); +#endif - /* At first, see if we are to do some GC ... */ - ++newcell_callcount; - if (++newcell_gc_callcount >= newcell_gc_interval) - cons_garbage_collect(); - /* Ok, if we were lucky, we got free cells from GC, - or had them otherwise.. */ - if (conscell_freechain == NULL) - if (new_consblock() == NULL) + ++newcell_callcount; + if (++newcell_gc_callcount >= newcell_gc_interval) + cons_garbage_collect(); + + /* Ok, if we were lucky, we got free cells from GC, + or had them otherwise.. */ + + if (conscell_freechain == NULL) + if (new_consblock() == NULL) if (cons_garbage_collect() == 0) { - /* XX: Unable to allocate memory, nor any freeable! - Print something, and abort ? */ - return NULL; + /* XX: Unable to allocate memory, nor any freeable! + Print something, and abort ? */ + return NULL; } - /* Ok, the devil is at loose now, if we don't have at least ONE cell - in the free chain now.. We do NOT store anything into flags, or - other fields of the structure -- to help memory access checkup - routines, like Purify, or DEC OSF/1 ATOM Third-Degree */ - new = conscell_freechain; - conscell_freechain = new->next; - new->next = NULL; - return new; + + /* Ok, the devil is at loose now, if we don't have at least ONE cell + in the free chain now.. We do NOT store anything into flags, or + other fields of the structure -- to help memory access checkup + routines, like Purify, or DEC OSF/1 ATOM Third-Degree */ + + new = conscell_freechain; + conscell_freechain = new->next; +#if 0 + new->next = NULL; +#else + memset(new, 0, sizeof(*new)); +#endif +#ifdef DEBUG + printf(" ... returns 0x%p\n", new); +#endif + return new; +} + +#ifdef DEBUG /* We test the beast... */ +int main(argc, argv) +int argc; +char *argv[]; +{ + int i; + conscell *newc, *tmp; + conscell *rootcell; + + newcell_gc_interval = 3; + + rootcell = conststring("const-string"); +#ifndef NO_CONSVARS + consvar_register(rootcell); +#endif + + for (i = 0; i < 30; ++i) { + newc = conststring("subconst"); + newc->next = rootcell->next; + rootcell->next = newc; + } + + return 0; } +#endif diff -u -r zmailer-2.99.49/smtpserver/smtpcmds.c zmailer-2.99.49p1/smtpserver/smtpcmds.c --- zmailer-2.99.49/smtpserver/smtpcmds.c Mon Jun 16 02:09:16 1997 +++ zmailer-2.99.49p1/smtpserver/smtpcmds.c Thu Jun 19 10:09:15 1997 @@ -435,8 +435,6 @@ POLICY_MAILFROM, cp, addrlen); if (SS->policyresult < 0) { type(SS, 553, "5.1.8", "The source address is in a reject list"); - if (s) - free((void *) s); #ifndef USE_ALLOCA if (newcp) free(newcp); @@ -669,8 +667,6 @@ fprintf(SS->mfp,">\n"); type(SS, 553, "5.1.8", "This is not acceptable target address"); - if (s) - free((void *) s); #ifndef USE_ALLOCA if (newcp) free((void *) newcp); diff -u -r zmailer-2.99.49/transports/libta/diagnostic.c zmailer-2.99.49p1/transports/libta/diagnostic.c --- zmailer-2.99.49/transports/libta/diagnostic.c Wed Jun 11 22:22:49 1997 +++ zmailer-2.99.49p1/transports/libta/diagnostic.c Tue Jun 17 14:48:42 1997 @@ -280,7 +280,7 @@ /* Right, we have a honour to append our diagnostics to the transport specification file ourselves */ int oldfl = fcntl(rp->desc->ctlfd, F_GETFL); - int len = 80 + strlen(notarybuf) + strlen(message); + int len = 80 + strlen(notarybuf ? notarybuf : "") + strlen(message); int rc2; long oldalarm; char *sbuf; @@ -297,17 +297,12 @@ #endif /* Log the diagnostic string to the file */ - len = -1; -#ifndef SPRINTF_CHAR - len = -#endif - sprintf(sbuf, "%c%c%d:%d:%d::%ld\t%s\t%s\n", - _CF_DIAGNOSTIC, _CFTAG_NORMAL, - rp->id, rp->headeroffset, rp->drptoffset, - (long)time(NULL), notarybuf, message); -#ifdef SPRINTF_CHAR + sprintf(sbuf, "%c%c%d:%d:%d::%ld\t%s\t%s\n", + _CF_DIAGNOSTIC, _CFTAG_NORMAL, + rp->id, rp->headeroffset, rp->drptoffset, + (long)time(NULL), notarybuf ? notarybuf : "", message); len = strlen(sbuf); -#endif + oldalarm = alarm(0); /* We do NOT want to be alarmed while writing to the log! */ @@ -330,7 +325,8 @@ fcntl(rp->desc->ctlfd, F_SETFL, oldfl); /* Now we have no reason to send also the NOTARY report up.. */ - *notarybuf = 0; + if (notarybuf != NULL) + *notarybuf = 0; } printf("%d/%d\t%s\t%s %s\n", diff -u -r zmailer-2.99.49/utils/makendbm/makendbm.c zmailer-2.99.49p1/utils/makendbm/makendbm.c --- zmailer-2.99.49/utils/makendbm/makendbm.c Sat Jun 14 21:20:51 1997 +++ zmailer-2.99.49p1/utils/makendbm/makendbm.c Tue Jun 17 19:08:02 1997 @@ -33,6 +33,8 @@ #include extern int errno; /* Not all systems declare it in ... */ +extern int optind; + /* extern char *strchr(); */ extern void create_dbase __((FILE *, void *, int)); @@ -148,12 +150,12 @@ /* Collect attribute pairs */ - str1 = strtok(s, " \t"); + str1 = (char *) strtok(s, " \t"); if (str1 == NULL) { printf("Error: No attribute pair on line %d.\n", linenum); } else { while (1) { - str2 = strtok(NULL, " \t"); + str2 = (char *) strtok(NULL, " \t"); if (str2 == NULL) { printf("Error: Invalid attribute pair on line %d.\n", linenum); @@ -163,7 +165,7 @@ str1, str2); policydatalen += policydata[policydatalen] & 0xFF; - str1 = strtok(NULL, " \t"); + str1 = (char *) strtok(NULL, " \t"); if (str1 == NULL) break; } @@ -288,7 +290,7 @@ /* makendbm [-ap] dbtype database.name [infilename|-] */ /* argv[] 0 1 2 3 4 */ - printf("optind = %d, argc = %d\n", optind, argc); + /* printf("optind = %d, argc = %d\n", optind, argc); */ if ((argc - optind) < 2) usage(argv0, "too few arguments", 0); diff -u -r zmailer-2.99.49/configure zmailer-2.99.49p1/configure --- zmailer-2.99.49/configure Sun Jun 15 02:31:50 1997 +++ zmailer-2.99.49p1/configure Thu Jun 19 20:10:18 1997 @@ -36,7 +36,7 @@ --with-system-malloc use system malloc instead of our own" ac_help="$ac_help --with-libmalloc=LIBNAME define the name of the malloc library - possible values: system, malloc_d, malloc (default)" + possible values: malloc, malloc_d, system (default)" ac_help="$ac_help --with-sendmailpath=PATH The location of the 'sendmail'" ac_help="$ac_help @@ -2177,16 +2177,16 @@ LIBMALLOC="" MALLOC="system" else - if test "x$withval" = xsystem ; then - LIBMALLOC="" - MALLOC="system" + if test "x$withval" = xmalloc_d -o "x$withval" = xmalloc ; then + LIBMALLOC="-l$withval" + MALLOC="$withval" + if text "$withval" = "malloc_d" ; then + MALLOCEXT="_d" + fi else - if test "x$withval" = xmalloc_d -o "x$withval" = xmalloc ; then - LIBMALLOC="-l$withval" - MALLOC="$withval" - if text "$withval" = "malloc_d" ; then - MALLOCEXT="_d" - fi + if test "x$withval" = xsystem -o "x$use_libmalloc" != x1; then + LIBMALLOC=""; MALLOCEXT="" + MALLOC="system" else eval LIBMALLOC="-l${MALLOC-malloc}" if test "x$LIBMALLOC" = "x-lmalloc_d"; then