Exemple #1
0
/* 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));
}
Exemple #2
0
/* set an array of cells to missing value
 * SetMemMV sets an array of cells to missing value
 */
void SetMemMV(
    void *buf,		/* write-only buffer with cells */
    size_t nrElements,      /* number of cells */
    CSF_CR cellRepr)         /* cell representation */
{
    size_t index;

    switch (cellRepr) {
    case CR_INT1:
        (void)memset(buf,MV_INT1,nrElements);
        break;
    case CR_INT2:
        for (index=0; index<nrElements; index++)
            ((INT2 *) buf)[index]=MV_INT2;
        break;
    case CR_INT4:
        for (index=0; index<nrElements; index++)
            ((INT4 *) buf)[index]=MV_INT4;
        break;
    default:
        (void)memset(buf,MV_UINT1,CSFSIZEOF(nrElements,cellRepr));
    }
}