[GRASS-SVN] r73506 - grass/trunk/lib/segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 9 04:59:14 PDT 2018
Author: mmetz
Date: 2018-10-09 04:59:14 -0700 (Tue, 09 Oct 2018)
New Revision: 73506
Modified:
grass/trunk/lib/segment/close.c
grass/trunk/lib/segment/get.c
grass/trunk/lib/segment/get_row.c
grass/trunk/lib/segment/put.c
grass/trunk/lib/segment/put_row.c
grass/trunk/lib/segment/setup.c
Log:
libsegment: failsafe handling of all-in-memory cache
Modified: grass/trunk/lib/segment/close.c
===================================================================
--- grass/trunk/lib/segment/close.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/close.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -35,7 +35,10 @@
if (SEG->open != 1)
return -1;
- if (SEG->scb) {
+ if (SEG->cache) {
+ G_free(SEG->cache);
+ }
+ else {
Segment_release(SEG);
close(SEG->fd);
unlink(SEG->fname);
@@ -43,9 +46,6 @@
SEG->fd = -1;
SEG->fname = NULL;
}
- else {
- G_free(SEG->cache);
- }
SEG->open = 0;
Modified: grass/trunk/lib/segment/get.c
===================================================================
--- grass/trunk/lib/segment/get.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/get.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -40,7 +40,7 @@
{
int index, n, i;
- if (!SEG->scb) {
+ if (SEG->cache) {
memcpy(buf, SEG->cache + ((size_t)row * SEG->ncols + col) * SEG->len, SEG->len);
return 1;
Modified: grass/trunk/lib/segment/get_row.c
===================================================================
--- grass/trunk/lib/segment/get_row.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/get_row.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -47,7 +47,7 @@
int scols;
int n, index;
- if (!SEG->scb) {
+ if (SEG->cache) {
memcpy(buf, SEG->cache + ((size_t)row * SEG->ncols) * SEG->len, SEG->len * SEG->ncols);
return 1;
Modified: grass/trunk/lib/segment/put.c
===================================================================
--- grass/trunk/lib/segment/put.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/put.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -46,7 +46,7 @@
{
int index, n, i;
- if (!SEG->scb) {
+ if (SEG->cache) {
memcpy(SEG->cache + ((size_t)row * SEG->ncols + col) * SEG->len, buf, SEG->len);
return 1;
Modified: grass/trunk/lib/segment/put_row.c
===================================================================
--- grass/trunk/lib/segment/put_row.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/put_row.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -50,7 +50,7 @@
int result;
off_t col;
- if (!SEG->scb) {
+ if (SEG->cache) {
memcpy(SEG->cache + ((size_t)row * SEG->ncols) * SEG->len, buf, SEG->len * SEG->ncols);
return 1;
Modified: grass/trunk/lib/segment/setup.c
===================================================================
--- grass/trunk/lib/segment/setup.c 2018-10-09 11:35:32 UTC (rev 73505)
+++ grass/trunk/lib/segment/setup.c 2018-10-09 11:59:14 UTC (rev 73506)
@@ -39,6 +39,7 @@
int seg_exp, n_total_segs;
SEG->open = 0;
+ SEG->cache = NULL;
if (SEG->nrows <= 0 || SEG->ncols <= 0
|| SEG->srows <= 0 || SEG->scols <= 0
More information about the grass-commit
mailing list