From 692fb5ed82bb9b6ee4be4d5463323585d142c0ea Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Thu, 17 Oct 2019 17:39:32 +0000 Subject: [PATCH] Solved some, still missing some --- src/snapshot.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/snapshot.c b/src/snapshot.c index 6d4c993..bbdb317 100644 --- a/src/snapshot.c +++ b/src/snapshot.c @@ -153,16 +153,13 @@ defstream.opaque = Z_NULL; defstream.avail_in = data_len+1; defstream.next_in = (unsigned char *)data; - char *compr=(char *)malloc(data_len*sizeof(char *)); + char *compr=(char *)malloc(data_len*sizeof(char)); defstream.avail_out = data_len+1; defstream.next_out = (unsigned char *)compr; deflateInit(&defstream, Z_BEST_COMPRESSION); deflate(&defstream, Z_FINISH); deflateEnd(&defstream); *compressed=compr; -// *compressed=base64_encode((unsigned char *)compr,(size_t)defstream.total_out,&nbase); - //fwrite(base64, sizeof(unsigned char), nbase, fh); -// free(compr); return defstream.total_out; } @@ -176,15 +173,16 @@ } char *ts_compress_intlist(int *data, ts_uint data_len){ - size_t nbase; + size_t nbase1, nbase2; char *compr; size_t number_of_compressed_bytes=ts_compress_data((char *)data, data_len*sizeof(int), &compr); - char *encoded_compressed=base64_encode((unsigned char *)compr,number_of_compressed_bytes,&nbase); + char *encoded_compressed=base64_encode((unsigned char *)compr,number_of_compressed_bytes,&nbase1); free(compr); - ts_uint header[4]={1, data_len, data_len, nbase}; - char *encoded_header=(char *)base64_encode((unsigned char *)header, 4*sizeof(ts_uint), &nbase); - encoded_header=realloc(encoded_header, 4*sizeof(ts_uint)+strlen(encoded_compressed)); + ts_uint header[4]={1, data_len, data_len, nbase1}; + char *encoded_header=(char *)base64_encode((unsigned char *)header, 4*sizeof(ts_uint), &nbase2); + encoded_header=realloc(encoded_header, nbase1+nbase2); encoded_header=strcat(encoded_header,encoded_compressed); + fprintf(stderr,"WAS HERE %d\n", data_len); free(encoded_compressed); return encoded_header; } -- Gitblit v1.9.3