summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-08-22 21:11:43 +0100
committerFreeArtMan <dos21h@gmail.com>2017-08-22 21:11:43 +0100
commit36d47490cd3fedffcfcf91f614842fe0c113b1ca (patch)
tree3b33ce064579a85af69912ad7578b9b9fc49ffb1
parentde6abbfddf1b0e15f444f4fe2a642d3a9775eec7 (diff)
downloadnetbytes-36d47490cd3fedffcfcf91f614842fe0c113b1ca.tar.gz
netbytes-36d47490cd3fedffcfcf91f614842fe0c113b1ca.zip
Fixed logical errors in nb_load
-rw-r--r--netbytes.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/netbytes.c b/netbytes.c
index 07c1301..81ba4d0 100644
--- a/netbytes.c
+++ b/netbytes.c
@@ -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: