summaryrefslogtreecommitdiff
path: root/test/test_add_elem.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-06-02 16:20:44 +0100
committerFreeArtMan <dos21h@gmail.com>2017-06-02 16:20:44 +0100
commita877a8ed7b508eb8cc5f7911dfcec8b8612470b3 (patch)
tree00b901522f01bad243cb14afc2f5ca8698ce5a37 /test/test_add_elem.c
parent65fb94f8fd98d343ae49f7d7e576418dba5a5d46 (diff)
downloadnetbytes-a877a8ed7b508eb8cc5f7911dfcec8b8612470b3.tar.gz
netbytes-a877a8ed7b508eb8cc5f7911dfcec8b8612470b3.zip
Fixed memleaks, rearranged some code
Diffstat (limited to 'test/test_add_elem.c')
-rw-r--r--test/test_add_elem.c16
1 files changed, 9 insertions, 7 deletions
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;