File: rmalloc.c

package info (click to toggle)
gdal 1.10.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,320 kB
  • ctags: 74,726
  • sloc: cpp: 677,199; ansic: 162,820; python: 13,816; cs: 11,163; sh: 10,446; java: 5,279; perl: 4,429; php: 2,971; xml: 1,500; yacc: 934; makefile: 494; sql: 112
file content (34 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (5)
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
33
34
/*
 * rmalloc.c 
 */
#include "csf.h"
#include "csfimpl.h"

/* allocate dynamic memory large enough to hold in-file and app cells
 * Rmalloc allocates memory to hold  nrOfCells 
 * cells in both the in-file and app cell representation. Allocation
 * is done by malloc for other users. Our own (utrecht university) applications
 * calls ChkMalloc. Freeing memory allocated by Rmalloc is done by free (or Free).
 *
 * NOTE
 * Note that a possible RuseAs call must be done BEFORE Rmalloc.
 *
 * returns
 * a pointer the allocated memory or
 * NULL
 * if the request fails
 *
 * example
 * .so examples/_row.tr
 */
void *Rmalloc(
	const MAP *m,      /* map handle */
	size_t nrOfCells)   /* number of cells allocated memory must hold */
{
	CSF_CR inFileCR = RgetCellRepr(m);
	CSF_CR largestCellRepr = 
		LOG_CELLSIZE(m->appCR) > LOG_CELLSIZE(inFileCR) 
		 ?  m->appCR : inFileCR;

	return CSF_MALLOC((size_t)CSFSIZEOF(nrOfCells, largestCellRepr));
}