From a877a8ed7b508eb8cc5f7911dfcec8b8612470b3 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Fri, 2 Jun 2017 16:20:44 +0100 Subject: Fixed memleaks, rearranged some code --- test/test_add_elem.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test/test_add_elem.c') diff --git a/test/test_add_elem.c b/test/test_add_elem.c index 5244880..7a789d1 100644 --- a/test/test_add_elem.c +++ b/test/test_add_elem.c @@ -66,10 +66,10 @@ int main() nb_u8 id; nb_u8arr name; - netbyte_store nb; + netbyte_store *nb=malloc(sizeof(netbyte_store)); printf("Start test\n"); - nb_init( &nb ); + nb_init( nb ); printf("Your name : "); fflush( stdin ); n = fgets( str, STR_SIZE, stdin ); @@ -82,21 +82,23 @@ int main() printf("er create u8arr: %d\n",er); - er = nb_add_u8( &nb, &id ); + er = nb_add_u8( nb, &id ); if (er) printf("er add u8: %d\n",er); - er = nb_add_u8arr( &nb, &name ); + er = nb_add_u8arr( nb, &name ); if (er) printf("er add u8arr: %d\n",er); - pr_store( &nb ); - res = nb_create( &nb ); + pr_store( nb ); + res = nb_create( nb ); f = fopen("test_many.nb","a"); - fwrite( res, 1, nb.size , f ); + fwrite( res, 1, nb->size , f ); fclose( f ); + free(res); + nb_free(nb); printf("End test\n"); return 0; -- cgit v1.2.3