/****************************************************************************** # # ###### # # # # ##### #### ## ## # ## ## # # # # # # # ## # ##### # ## # # # ##### # # # # # # # # # # ### # # # # # # # # # # ### # # # # ###### # # ###### # ##### ### #### ******************************************************************************/ /* This file is part of MAPMAKER 3.0b, Copyright 1987-1992, Whitehead Institute for Biomedical Research. All rights reserved. See READ.ME for license. */ #define INC_IO #define INC_STR #define INC_MSG #define INC_MEM #define INC_HELP_DEFS #include "system.h" CALLOC_PTR_TO *xalloc(); /* INTERNAL USE ONLY! */ int verbose_mem; /* may be set by user */ long n_alloced; int yy, zz; #define ALLOC_MSG \ "alloc:\t%dx%d\tbytes @ %8lxH. total bytes alloced=%ld\n" #define ALLOC_FAIL_MSG \ "FAILED:\t%dx%d\tbytes total bytes alloced=%ld\n" CALLOC_PTR_TO *xalloc(num,cell_sizeof) CALLOC_NUM_TYPE num; SIZEOF_TYPE cell_sizeof; { CALLOC_PTR_TO *p; long chars; if (num==REALLY_1) num=1; else if (num<=0) send(CRASH); else num++; /* paranoia */ chars=num*cell_sizeof; /* Note that this test will be inadequate if word-aligning causes things to take up more space than their sizeof()! */ /* if (chars > 65472L) send(CRASH); 64K-64 bytes max KLUDGE */ if ((p=calloc((CALLOC_NUM_TYPE)num,cell_sizeof))==NULL) { if (TRUE || verbose_mem) { /* KLUDGE */ sf(ps_,ALLOC_FAIL_MSG,num,cell_sizeof,n_alloced); print(ps_); } NOMEMORY_num_cells= (int)num; NOMEMORY_cell_size= (int)cell_sizeof; return(NULL); } else { /* all is OK */ if (verbose_mem) { sprintf(ps_,ALLOC_MSG,num,cell_sizeof,((long)p),n_alloced); print(ps_); } n_alloced+= ((long)num) * ((long)cell_sizeof); return(p); } } real ***alloc_real_3d_matrix(i,j,k) int i,j,k; { int z; real ***p; run { array(p,i,real**); for (z=0; z