From 201659654a328f84c229d16fe85d8709a4183957 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Sat, 19 Oct 2019 15:53:42 +0000
Subject: [PATCH] Fixed most problems, some still persists.

---
 src/restore.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/restore.c b/src/restore.c
index a1211ea..7079960 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -344,6 +344,7 @@
 //				vals=(char *)values;
 				unsigned long data_len=0;
 				ts_double *curv_values=(double *)ts_decompress((unsigned char *)values,strlen((char *)values), &data_len);
+				data_len=data_len/sizeof(ts_double);
 //				token=strtok(vals," ");
 				for(idx=0;idx<data_len;idx++){
 //				while(token!=NULL){
@@ -362,7 +363,9 @@
 					//idx++;
 					//token=strtok(NULL," ");
 				}
+				
 				xmlFree(values);		
+				free(curv_values);
 			}
 			xmlFree(property_name);
 		}
@@ -376,18 +379,19 @@
 	xmlNodePtr child = cur->xmlChildrenNode;
 	xmlChar *points;
 //	char *pts;
-	int idx, polyidx, monoidx, filidx, fonoidx;
+	int i,idx, polyidx, monoidx, filidx, fonoidx;
 //	char *token[3];
 	while (child != NULL) {
 		if ((!xmlStrcmp(child->name, (const xmlChar *)"DataArray"))){
 			points = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
 			unsigned long data_len=0;
 			ts_double *coords=(double *)ts_decompress((unsigned char *)points,strlen((char *)points), &data_len);
+			data_len=data_len/sizeof(ts_double);
 			//pts=(char *)points;
 			//token[0]=strtok(pts," ");
 			//token[1]=strtok(NULL," ");
 			//token[2]=strtok(NULL,"\n");
-			for(idx=0;idx<data_len;idx+=3){
+			for(i=0,idx=0;i<data_len;i+=3,idx++){
 //			while(token[0]!=NULL){
 				if(idx<vesicle->vlist->n){
 					vesicle->vlist->vtx[idx]->x=coords[idx];//atof(token[0]);
@@ -424,7 +428,7 @@
 	xmlNodePtr child = cur->xmlChildrenNode;
 	xmlChar *bonds, *conname;
 //	char *b;
-	int idx, polyidx;
+	int i,idx, polyidx;
 //	char *token[2];
 //	int temp_cnt=0;
 	while (child != NULL) {
@@ -433,9 +437,10 @@
 			bonds = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
 			unsigned long data_len=0;
 			unsigned long *conn=(unsigned long *)ts_decompress((unsigned char *)bonds,strlen((char *)bonds), &data_len);
+			data_len=data_len/sizeof(unsigned long);
 			//token[0]=strtok(b," ");
 			//token[1]=strtok(NULL,"\n");
-			for(idx=0;idx<data_len;idx+=2){
+			for(i=0,idx=0;i<data_len;i+=2,idx++){
 //			while(token[0]!=NULL){
 				if(idx<3*(vesicle->vlist->n-2)){
 					bond_add(vesicle->blist, vesicle->vlist->vtx[conn[idx]], vesicle->vlist->vtx[conn[idx+1]]);

--
Gitblit v1.9.3