1 #include <stdlib.h>
2 
3 #include "csf.h"
4 #include "csfimpl.h"
5 
6 /* make all cells missing value in map
7  * RputAllMV writes a missing values to all the cells in a
8  * map. For this is allocates a buffer to hold one row at a
9  * time.
10  * returns 1 if successfully, 0 in case of an error
11  */
RputAllMV(MAP * m)12 int RputAllMV(
13 	MAP *m)
14 {
15 	size_t i,nc,nr;
16 	void *buffer;
17 	CSF_CR cr;
18 
19 	CHECKHANDLE_GOTO(m, error);
20 	if(! WRITE_ENABLE(m))
21 	{
22 		M_ERROR(NOACCESS);
23 		goto error;
24 	}
25 
26 	cr = RgetCellRepr(m);
27 	nc = RgetNrCols(m);
28 
29 	buffer = Rmalloc(m,nc);
30 	if(buffer == NULL)
31 	{
32 		M_ERROR(NOCORE);
33 		goto error;
34 	}
35 
36 	/*  Fill buffer with determined Missingvalue*/
37 	SetMemMV(buffer, nc, cr);
38 
39 	nr = RgetNrRows(m);
40 	for(i = 0 ; i < nr; i++)
41 	 if (RputRow(m, i, buffer) != nc)
42 	 {
43 	    M_ERROR(WRITE_ERROR);
44 	    goto error_f;
45 	 }
46 	CSF_FREE(buffer);
47 
48 	CsfSetVarTypeMV( &(m->raster.minVal), cr);
49 	CsfSetVarTypeMV( &(m->raster.maxVal), cr);
50 
51 	return(1);
52 error_f:
53 	CSF_FREE(buffer);
54 error:
55 	return(0);
56 }
57