mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Save fixes.
This commit is contained in:
parent
7e964d4370
commit
87b11024cd
|
@ -2570,9 +2570,10 @@ void messenger_save(const Messenger *m, uint8_t *data)
|
|||
uint32_t *data32, size32 = sizeof(uint32_t);
|
||||
|
||||
data32 = (uint32_t *)data;
|
||||
data32[0] = 0;
|
||||
data32[1] = MESSENGER_STATE_COOKIE_GLOBAL;
|
||||
data += size32 * 2;
|
||||
memset(data, 0, size32);
|
||||
data += size32;
|
||||
host_to_lendian32(data, MESSENGER_STATE_COOKIE_GLOBAL);
|
||||
data += size32;
|
||||
|
||||
#ifdef DEBUG
|
||||
assert(sizeof(get_nospam(&(m->fr))) == sizeof(uint32_t));
|
||||
|
@ -2748,7 +2749,8 @@ int messenger_load(Messenger *m, const uint8_t *data, uint32_t length)
|
|||
if (length < cookie_len)
|
||||
return -1;
|
||||
|
||||
memcpy(data32, data, sizeof(data32));
|
||||
memcpy(data32, data, sizeof(uint32_t));
|
||||
lendian_to_host32(data32 + 1, data + sizeof(uint32_t));
|
||||
|
||||
if (!data32[0] && (data32[1] == MESSENGER_STATE_COOKIE_GLOBAL))
|
||||
return load_state(messenger_load_state_callback, m, data + cookie_len,
|
||||
|
|
|
@ -47,6 +47,7 @@ uint16_t lendian_to_host16(uint16_t lendian);
|
|||
#define host_tolendian16(x) lendian_to_host16(x)
|
||||
|
||||
void host_to_lendian32(uint8_t *dest, uint32_t num);
|
||||
void lendian_to_host32(uint32_t *dest, const uint8_t *lendian);
|
||||
|
||||
/* state load/save */
|
||||
typedef int (*load_state_callback_func)(void *outer, const uint8_t *data, uint32_t len, uint16_t type);
|
||||
|
|
Loading…
Reference in New Issue
Block a user