contrib/tcsh-6/tc.alloc.c
static void
morecore(int bucket)
{
    union overhead *op;
    int rnu;		/* 2^rnu bytes will be requested */
    int nblks;		/* become nblks blocks of the desired size */
    int siz;

    if (nextf[bucket])
	return;
    /*
     * Insure memory is allocated on a page boundary.  Should make getpageize
     * call?
     */
    op = (union overhead *) sbrk(0);
    memtop = (char *) op;
    if (membot == NULL)
	membot = memtop;
    if ((long) op & 0x3ff) {
	memtop = sbrk((int) (1024 - ((long) op & 0x3ff)));
	memtop += (long) (1024 - ((long) op & 0x3ff));
    }

    /* take 2k unless the block is bigger than that */
    rnu = (bucket <= 8) ? 11 : bucket + 3;
    nblks = 1 << (rnu - (bucket + 3));	/* how many blocks to get */
    memtop = sbrk(1 << rnu);	/* PWP */
    op = (union overhead *) memtop;
    /* no more room! */
    if ((long) op == -1)
	return;
    memtop += (long) (1 << rnu);
    /*
     * Round up to minimum allocation size boundary and deduct from block count
     * to reflect.
     */
    if (((U_long) op) & ROUNDUP) {
	op = (union overhead *) (((U_long) op + (ROUNDUP + 1)) & ~ROUNDUP);
	nblks--;
    }
    /*
     * Add new memory allocated to that on free list for this hash bucket.
     */
    nextf[bucket] = op;
    siz = 1 << (bucket + 3);
    while (--nblks > 0) {
	op->ov_next = (union overhead *) (((caddr_t) op) + siz);
	op = (union overhead *) (((caddr_t) op) + siz);
    }
    op->ov_next = NULL;
}
/*
 * Allocate more memory to the indicated bucket.
 */
Allocate more memory to the indicated bucket.
Allocate more memory to the indicated bucket .
static void
morecore(int bucket)
{
    union overhead *op;
    int rnu;		
    int nblks;		
    int siz;
    if (nextf[bucket])
	return;
    op = (union overhead *) sbrk(0);
    memtop = (char *) op;
    if (membot == NULL)
	membot = memtop;
    if ((long) op & 0x3ff) {
	memtop = sbrk((int) (1024 - ((long) op & 0x3ff)));
	memtop += (long) (1024 - ((long) op & 0x3ff));
    }
    rnu = (bucket <= 8) ? 11 : bucket + 3;
    nblks = 1 << (rnu - (bucket + 3));	
    memtop = sbrk(1 << rnu);	
    op = (union overhead *) memtop;
    if ((long) op == -1)
	return;
    memtop += (long) (1 << rnu);
    if (((U_long) op) & ROUNDUP) {
	op = (union overhead *) (((U_long) op + (ROUNDUP + 1)) & ~ROUNDUP);
	nblks--;
    }
    nextf[bucket] = op;
    siz = 1 << (bucket + 3);
    while (--nblks > 0) {
	op->ov_next = (union overhead *) (((caddr_t) op) + siz);
	op = (union overhead *) (((caddr_t) op) + siz);
    }
    op->ov_next = NULL;
}
static void morecore ( int bucket ) { union overhead * op ; int rnu ; int nblks ; int siz ; if ( nextf [ bucket ] ) return ; op = ( union overhead * ) sbrk ( 0 ) ; memtop = ( char * ) op ; if ( membot == NULL ) membot = memtop ; if ( ( long ) op & 0x3ff ) { memtop = sbrk ( ( int ) ( 1024 - ( ( long ) op & 0x3ff ) ) ) ; memtop += ( long ) ( 1024 - ( ( long ) op & 0x3ff ) ) ; } rnu = ( bucket <= 8 ) ? 11 : bucket + 3 ; nblks = 1 << ( rnu - ( bucket + 3 ) ) ; memtop = sbrk ( 1 << rnu ) ; op = ( union overhead * ) memtop ; if ( ( long ) op == -1 ) return ; memtop += ( long ) ( 1 << rnu ) ; if ( ( ( U_long ) op ) & ROUNDUP ) { op = ( union overhead * ) ( ( ( U_long ) op + ( ROUNDUP + 1 ) ) & ~ ROUNDUP ) ; nblks -- ; } nextf [ bucket ] = op ; siz = 1 << ( bucket + 3 ) ; while ( -- nblks > 0 ) { op -> ov_next = ( union overhead * ) ( ( ( caddr_t ) op ) + siz ) ; op = ( union overhead * ) ( ( ( caddr_t ) op ) + siz ) ; } op -> ov_next = NULL ; }
Allocate more memory to the indicated bucket.
Allocate more memory to the indicated bucket .
/* 2^rnu bytes will be requested */ /* become nblks blocks of the desired size */ /*
     * Insure memory is allocated on a page boundary.  Should make getpageize
     * call?
     */ /* take 2k unless the block is bigger than that */ /* how many blocks to get */ /* PWP */ /* no more room! */ /*
     * Round up to minimum allocation size boundary and deduct from block count
     * to reflect.
     */ /*
     * Add new memory allocated to that on free list for this hash bucket.
     */