61 |
|
static int nhdfragls; /* size of hdfragl array */ |
62 |
|
|
63 |
|
|
64 |
+ |
HOLO * |
65 |
+ |
hdalloc(hproto) /* allocate and set holodeck section based on grid */ |
66 |
+ |
HDGRID *hproto; |
67 |
+ |
{ |
68 |
+ |
HOLO hdhead; |
69 |
+ |
register HOLO *hp; |
70 |
+ |
int n; |
71 |
+ |
/* copy grid to temporary header */ |
72 |
+ |
bcopy((char *)hproto, (char *)&hdhead, sizeof(HDGRID)); |
73 |
+ |
/* compute grid vectors and sizes */ |
74 |
+ |
hdcompgrid(&hdhead); |
75 |
+ |
/* allocate header with directory */ |
76 |
+ |
n = sizeof(HOLO)+nbeams(&hdhead)*sizeof(BEAMI); |
77 |
+ |
if ((hp = (HOLO *)malloc(n)) == NULL) |
78 |
+ |
return(NULL); |
79 |
+ |
/* copy header information */ |
80 |
+ |
copystruct(hp, &hdhead); |
81 |
+ |
/* allocate and clear beam list */ |
82 |
+ |
hp->bl = (BEAM **)malloc((nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); |
83 |
+ |
if (hp->bl == NULL) { |
84 |
+ |
free((char *)hp); |
85 |
+ |
return(NULL); |
86 |
+ |
} |
87 |
+ |
bzero((char *)hp->bl, (nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); |
88 |
+ |
hp->bl[0] = (BEAM *)(hp->bl+nbeams(hp)+1); /* set blglob(hp) */ |
89 |
+ |
hp->fd = -1; |
90 |
+ |
hp->dirty = 0; |
91 |
+ |
hp->priv = NULL; |
92 |
+ |
/* clear beam directory */ |
93 |
+ |
bzero((char *)hp->bi, (nbeams(hp)+1)*sizeof(BEAMI)); |
94 |
+ |
return(hp); /* all is well */ |
95 |
+ |
} |
96 |
+ |
|
97 |
+ |
|
98 |
|
char * |
99 |
|
hdrealloc(ptr, siz, rout) /* (re)allocate memory, retry then error */ |
100 |
|
char *ptr; |