Annotation of 43BSD/ucb/window/wwalloc.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)wwalloc.c  3.7 4/24/85";
        !             3: #endif
        !             4: 
        !             5: /*
        !             6:  * Copyright (c) 1983 Regents of the University of California,
        !             7:  * All rights reserved.  Redistribution permitted subject to
        !             8:  * the terms of the Berkeley Software License Agreement.
        !             9:  */
        !            10: 
        !            11: #include "ww.h"
        !            12: 
        !            13: char **
        !            14: wwalloc(row, col, nrow, ncol, size)
        !            15: {
        !            16:        register char *p, **pp;
        !            17:        register int i;
        !            18: 
        !            19:        /* fast, call malloc only once */
        !            20:        pp = (char **)
        !            21:                malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
        !            22:        if (pp == 0) {
        !            23:                wwerrno = WWE_NOMEM;
        !            24:                return 0;
        !            25:        }
        !            26:        p = (char *)&pp[nrow];
        !            27:        col *= size;
        !            28:        size /= sizeof (char);          /* paranoid */
        !            29:        size *= ncol;
        !            30:        for (i = 0; i < nrow; i++) {
        !            31:                pp[i] = p - col;
        !            32:                p += size;
        !            33:        }
        !            34:        return pp - row;
        !            35: }
        !            36: 
        !            37: wwfree(p, row)
        !            38: register char **p;
        !            39: {
        !            40:        free((char *)(p + row));
        !            41: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.