diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-08-22 21:11:43 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-08-22 21:11:43 +0100 |
commit | 36d47490cd3fedffcfcf91f614842fe0c113b1ca (patch) | |
tree | 3b33ce064579a85af69912ad7578b9b9fc49ffb1 /netbytes.c | |
parent | de6abbfddf1b0e15f444f4fe2a642d3a9775eec7 (diff) | |
download | netbytes-36d47490cd3fedffcfcf91f614842fe0c113b1ca.tar.gz netbytes-36d47490cd3fedffcfcf91f614842fe0c113b1ca.zip |
Fixed logical errors in nb_load
Diffstat (limited to 'netbytes.c')
-rw-r--r-- | netbytes.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -539,14 +539,12 @@ int nb_load( netbyte_store *store, uint8_t *data ) { case NBT_U8: { - nb_u8 *u8 = malloc( sizeof(nb_u8) ); + nb_u8 u8; - memcpy( u8, c, sizeof(nb_u8) ); + memcpy( &u8, c, sizeof(nb_u8) ); c += sizeof(nb_u8); - nb_add_u8( store, u8 ); - - free(u8); + nb_add_u8( store, &u8 ); break; } @@ -572,12 +570,12 @@ int nb_load( netbyte_store *store, uint8_t *data ) } case NBT_U16: { - nb_u16 *u16 = malloc( sizeof(nb_u16) ); + nb_u16 u16; - memcpy( u16, c, sizeof(nb_u16) ); + memcpy( &u16, c, sizeof(nb_u16) ); c += sizeof(nb_u16); - nb_add_u16( store, u16 ); + nb_add_u16( store, &u16 ); break; } @@ -600,8 +598,6 @@ int nb_load( netbyte_store *store, uint8_t *data ) } case NBT_U32: { - //FIXIT in all places - //nb_u32 *u32 = malloc( sizeof(nb_u32) ); nb_u32 u32; memcpy( &u32, c, sizeof(nb_u32) ); @@ -629,12 +625,12 @@ int nb_load( netbyte_store *store, uint8_t *data ) } case NBT_U64: { - nb_u64 *u64 = malloc( sizeof(nb_u64) ); + nb_u64 u64; - memcpy( u64, c, sizeof(nb_u64) ); + memcpy( &u64, c, sizeof(nb_u64) ); c += sizeof(nb_u64); - nb_add_u64( store, u64 ); + nb_add_u64( store, &u64 ); break; } case NBT_U64ARRAY: |