summaryrefslogtreecommitdiff
path: root/test/test_alltypes.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_alltypes.c
parent65fb94f8fd98d343ae49f7d7e576418dba5a5d46 (diff)
downloadnetbytes-a877a8ed7b508eb8cc5f7911dfcec8b8612470b3.tar.gz
netbytes-a877a8ed7b508eb8cc5f7911dfcec8b8612470b3.zip
Fixed memleaks, rearranged some code
Diffstat (limited to 'test/test_alltypes.c')
-rw-r--r--test/test_alltypes.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/test/test_alltypes.c b/test/test_alltypes.c
index 2975d2a..b6eb801 100644
--- a/test/test_alltypes.c
+++ b/test/test_alltypes.c
@@ -104,8 +104,7 @@ int main()
{
FILE *f=NULL;
int er;
- netbyte_store nb;
- netbyte_store nb2;
+ netbyte_store *nb = malloc(sizeof(netbyte_store));
nb_u8 u8;
nb_u8arr u8arr;
nb_u16 u16;
@@ -120,7 +119,7 @@ int main()
printf("Start test\n");
- nb_init( &nb );
+ nb_init( nb );
er = nb_u8_create( &u8, 0x10 );
if (er)
printf("er create u8: %d\n",er);
@@ -142,8 +141,8 @@ int main()
pr_u8arr( &u8arr );
#if 1
- pr_store( &nb );
- er = nb_add_u8( &nb, &u8 );
+ pr_store( nb );
+ er = nb_add_u8( nb, &u8 );
if (er)
printf("er add u8: %d\n",er);
#endif
@@ -156,54 +155,39 @@ int main()
#endif
#if 1
- pr_store( &nb );
- er = nb_add_u16( &nb, &u16 );
+ pr_store( nb );
+ er = nb_add_u16( nb, &u16 );
if (er)
printf("er add u16: %d\n",er);
#endif
#if 1
- pr_store( &nb );
- er = nb_add_u32( &nb, &u32 );
+ pr_store( nb );
+ er = nb_add_u32( nb, &u32 );
if (er)
printf("er add u32: %d\n",er);
#endif
#if 1
- pr_store( &nb );
- er = nb_add_u64( &nb, &u64 );
+ pr_store( nb );
+ er = nb_add_u64( nb, &u64 );
if (er)
printf("er add u64: %d\n",er);
#endif
- pr_store( &nb );
- res = nb_create( &nb );
- pr_store( &nb );
+ pr_store( nb );
+ res = nb_create( nb );
+ pr_store( nb );
printf("res 0x%x\n", res);
f = fopen("test_alltypes.nb","w+");
- fwrite( res, 1, nb.size , f );
+ fwrite( res, 1, nb->size , f );
fclose( f );
- /*
- printf("LOAD:-----\n");
- nb_init( &nb2 );
- pr_store( &nb2 );
- nb_load( &nb2, res );
- pr_store( &nb2 );
-
- printf( "->1 [%s]\n", ((nb_u8arr *)nb2.types[1].nb_val)->val );
-
- __NBT_TYPED *t=0xf8;
- nb_u8arr *v;
- nb_type( &nb2, 1, &t );
- printf("get type: %02x\n", t );
- nb_val( &nb2, 1, (uint8_t **)&v );
- printf("get value: %02x\n", v->val );
- */
-
free( res );
+ nb_free(nb);
+
printf("End test\n");
return 0;