ldmud-3.2.9/doc/
ldmud-3.2.9/doc/efun/
ldmud-3.2.9/mud/
ldmud-3.2.9/mud/heaven7/
ldmud-3.2.9/mud/heaven7/lib/
ldmud-3.2.9/mud/lp-245/
ldmud-3.2.9/mud/lp-245/banish/
ldmud-3.2.9/mud/lp-245/doc/
ldmud-3.2.9/mud/lp-245/doc/examples/
ldmud-3.2.9/mud/lp-245/doc/sefun/
ldmud-3.2.9/mud/lp-245/log/
ldmud-3.2.9/mud/lp-245/obj/Go/
ldmud-3.2.9/mud/lp-245/players/lars/
ldmud-3.2.9/mud/lp-245/room/death/
ldmud-3.2.9/mud/lp-245/room/maze1/
ldmud-3.2.9/mud/lp-245/room/sub/
ldmud-3.2.9/mud/lp-245/secure/
ldmud-3.2.9/mud/morgengrauen/
ldmud-3.2.9/mud/morgengrauen/lib/
ldmud-3.2.9/mud/sticklib/
ldmud-3.2.9/mud/sticklib/src/
ldmud-3.2.9/mudlib/uni-crasher/
ldmud-3.2.9/pkg/
ldmud-3.2.9/pkg/debugger/
ldmud-3.2.9/pkg/diff/
ldmud-3.2.9/pkg/misc/
ldmud-3.2.9/src/autoconf/
ldmud-3.2.9/src/bugs/
ldmud-3.2.9/src/bugs/MudCompress/
ldmud-3.2.9/src/bugs/b-020916-files/
ldmud-3.2.9/src/bugs/doomdark/
ldmud-3.2.9/src/bugs/ferrycode/ferry/
ldmud-3.2.9/src/bugs/ferrycode/obj/
ldmud-3.2.9/src/bugs/psql/
ldmud-3.2.9/src/done/
ldmud-3.2.9/src/done/order_alist/
ldmud-3.2.9/src/done/order_alist/obj/
ldmud-3.2.9/src/done/order_alist/room/
ldmud-3.2.9/src/gcc/
ldmud-3.2.9/src/gcc/2.7.0/
ldmud-3.2.9/src/gcc/2.7.1/
ldmud-3.2.9/src/hosts/
ldmud-3.2.9/src/hosts/GnuWin32/
ldmud-3.2.9/src/hosts/amiga/NetIncl/
ldmud-3.2.9/src/hosts/amiga/NetIncl/netinet/
ldmud-3.2.9/src/hosts/amiga/NetIncl/sys/
ldmud-3.2.9/src/hosts/i386/
ldmud-3.2.9/src/hosts/msdos/byacc/
ldmud-3.2.9/src/hosts/msdos/doc/
ldmud-3.2.9/src/hosts/os2/
ldmud-3.2.9/src/hosts/win32/
ldmud-3.2.9/src/util/
ldmud-3.2.9/src/util/erq/
ldmud-3.2.9/src/util/indent/hosts/next/
ldmud-3.2.9/src/util/xerq/
ldmud-3.2.9/src/util/xerq/lpc/
ldmud-3.2.9/src/util/xerq/lpc/www/
/*---------------------------------------------------------------------------
 * Determine the malloc() overhead.
 *
 *---------------------------------------------------------------------------
 * Utilityprogram for the configure script to estimate the overhead
 * of the system malloc(). The algorithm is to allocate two blocks and
 * measuring the difference in addresses. This is repeated for various
 * block sizes and the minimum of the found differences is selected.
 *
 * Usage: overhead [--terse]
 *
 * If '--terse' is given, overhead prints just the number otherwise
 * a nice message.
 *
 * Exit status is 1 if the overhead could not be determined.
 *---------------------------------------------------------------------------
 */

#include <stdio.h>
#if defined(HAVE_STDLIB_H) || defined(AMIGA)
#  include <stdlib.h>
#endif
#ifdef HAVE_LIBC_H
#  include <libc.h>
#endif

/*-------------------------------------------------------------------------*/
int
main (int argc, char **argv)

{
    int i, d, min;
    char *p, *q;
    int terse;
    int total = 12, negative = 0, min_index = 0;

    terse = argc > 1 && !strcmp(argv[1], "--terse");

    i = 0x8000;
    min = i;
    d = i;
    do
    {
	p = malloc(i);
	q = malloc(i);
	total++;
	d = q - (p+i);
	if (d <= min)
	{
	    if (d < 0)
	    {
		negative++;
		if (negative*3 > total*2)
		{
		    fprintf(
		      stderr,
		      "Malloc returns does not return increasing addresses\n"
		    );
		    if (terse)
			printf("0");
		    exit(1);
		}
		continue;
	    }
	    if (d == min)
		break;
	    min = d;
	    min_index = i;
	    if (d == 0)
		break;
	}
	i -= sizeof(char *);
    } while (i >= 0x7f00);

    d = 0x8000 - min_index;

    if (d > 0x100 || min > 0x1000)
    {
	fprintf(stderr, "no credible value for EXTERN_MALLOC_OVERHEAD found\n");
	if (terse)
	    printf("0");
	fflush(stdout);
	exit(1);
    }

    printf(terse ? "%d" : "Suggested EXTERN_MALLOC_OVERHEAD: %d\n", d);
    if (!terse && d != min)
	printf("Actual overhead encountered for the above setting:%d\n", min);
    return 0;
} /* main() */

/***************************************************************************/