PageRenderTime 113ms CodeModel.GetById 108ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/vector1.c

http://github.com/route-me/route-me
C | 33 lines | 30 code | 2 blank | 1 comment | 5 complexity | d4e2f574e50947cd389b8f6a7bab88c6 MD5 | raw file
 1/* make storage for one and two dimensional matricies */
 2#ifndef lint
 3static const char SCCSID[]="@(#)vector1.c	4.4	94/03/22	GIE	REL";
 4#endif
 5#include <stdlib.h>
 6#include "projects.h"
 7	void * /* one dimension array */
 8vector1(int nvals, int size) { return((void *)pj_malloc(size * nvals)); }
 9	void /* free 2D array */
10freev2(void **v, int nrows) {
11	if (v) {
12		for (v += nrows; nrows > 0; --nrows)
13			pj_dalloc(*--v);
14		pj_dalloc(v);
15	}
16}
17	void ** /* two dimension array */
18vector2(int nrows, int ncols, int size) {
19	void **s;
20
21	s = (void **)pj_malloc(sizeof(void *) * nrows);
22	if (s) {
23		int rsize, i;
24
25		rsize = size * ncols;
26		for (i = 0; i < nrows; ++i)
27			if (!(s[i] = pj_malloc(rsize))) {
28				freev2(s, i);
29				return (void **)0;
30			}
31	}
32	return s;
33}