Menu

[r5472]: / trunk / toolkits / basemap / src / vector1.c  Maximize  Restore  History

Download this file

33 lines (30 with data), 752 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* make storage for one and two dimensional matricies */
#ifndef lint
static const char SCCSID[]="@(#)vector1.c 4.4 94/03/22 GIE REL";
#endif
#include <stdlib.h>
#include <projects.h>
void * /* one dimension array */
vector1(int nvals, int size) { return((void *)pj_malloc(size * nvals)); }
void /* free 2D array */
freev2(void **v, int nrows) {
if (v) {
for (v += nrows; nrows > 0; --nrows)
pj_dalloc(*--v);
pj_dalloc(v);
}
}
void ** /* two dimension array */
vector2(int nrows, int ncols, int size) {
void **s;
if (s = (void **)pj_malloc(sizeof(void *) * nrows)) {
int rsize, i;
rsize = size * ncols;
for (i = 0; i < nrows; ++i)
if (!(s[i] = pj_malloc(rsize))) {
freev2(s, i);
return (void **)0;
}
}
return s;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.