[GRASS-SVN] r54877 - in grass/trunk: include/defs lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 3 11:28:53 PST 2013
Author: mmetz
Date: 2013-02-03 11:28:53 -0800 (Sun, 03 Feb 2013)
New Revision: 54877
Modified:
grass/trunk/include/defs/ogsf.h
grass/trunk/lib/ogsf/gvl_calc.c
Log:
ogsflib: fix for #1736
Modified: grass/trunk/include/defs/ogsf.h
===================================================================
--- grass/trunk/include/defs/ogsf.h 2013-02-03 18:25:56 UTC (rev 54876)
+++ grass/trunk/include/defs/ogsf.h 2013-02-03 19:28:53 UTC (rev 54877)
@@ -715,7 +715,7 @@
int gvl_slices_calc(geovol *);
void gvl_write_char(int, unsigned char **, unsigned char);
unsigned char gvl_read_char(int, const unsigned char *);
-void gvl_align_data(int, unsigned char *);
+void gvl_align_data(int, unsigned char **);
/* gvld.c */
int gvld_vol(geovol *);
Modified: grass/trunk/lib/ogsf/gvl_calc.c
===================================================================
--- grass/trunk/lib/ogsf/gvl_calc.c 2013-02-03 18:25:56 UTC (rev 54876)
+++ grass/trunk/lib/ogsf/gvl_calc.c 2013-02-03 19:28:53 UTC (rev 54877)
@@ -687,7 +687,7 @@
if (dbuff[i].old == isosurf->data)
dbuff[i].old = NULL;
G_free(isosurf->data);
- gvl_align_data(dbuff[i].ndx_new, dbuff[i].new);
+ gvl_align_data(dbuff[i].ndx_new, &(dbuff[i].new));
isosurf->data = dbuff[i].new;
isosurf->data_desc = 0;
}
@@ -776,16 +776,24 @@
\param pos position index
\param data data buffer
*/
-void gvl_align_data(int pos, unsigned char *data)
+void gvl_align_data(int pos, unsigned char **data)
{
+ unsigned char *p = *data;
+
+
/* realloc memory to fit in data length */
- data = (char *)G_realloc(data, sizeof(char) * pos); /* G_fatal_error */
- if (!data) {
+ p = (char *)G_realloc(p, sizeof(char) * pos); /* G_fatal_error */
+ if (!p) {
return;
}
G_debug(3, "gvl_align_data(): reallocate memory finally to : %d B", pos);
+ if (pos == 0)
+ p = NULL;
+
+ *data = p;
+
return;
}
@@ -1014,7 +1022,7 @@
/* end reading volume file */
gvl_file_end_read(vf);
- gvl_align_data(pos, slice->data);
+ gvl_align_data(pos, &(slice->data));
return (1);
}
More information about the grass-commit
mailing list