mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Minor cleanup of event unpack code.
This commit is contained in:
parent
bdf460a3a9
commit
6aa9e6850d
|
@ -1 +1 @@
|
||||||
48ed699a0da0282b7e12142648a322198a2f2af791df3fb49bbe3f7e41afadc4 /usr/local/bin/tox-bootstrapd
|
7dfcf534fb80fbd8337337f5aa9eaa120febc72386046c7ab0d5c7545e900657 /usr/local/bin/tox-bootstrapd
|
||||||
|
|
|
@ -940,7 +940,7 @@ static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
static bool tox_event_type_unpack(Bin_Unpack *bu, Tox_Event_Type *val)
|
static bool tox_event_type_unpack(Tox_Event_Type *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
|
@ -1080,21 +1080,7 @@ static bool tox_event_data_unpack(Tox_Event_Type type, Tox_Event_Data *data, Bin
|
||||||
|
|
||||||
bool tox_event_unpack_into(Tox_Event *event, Bin_Unpack *bu, const Memory *mem)
|
bool tox_event_unpack_into(Tox_Event *event, Bin_Unpack *bu, const Memory *mem)
|
||||||
{
|
{
|
||||||
uint32_t size;
|
return bin_unpack_array_fixed(bu, 2, nullptr) //
|
||||||
if (!bin_unpack_array(bu, &size)) {
|
&& tox_event_type_unpack(&event->type, bu) //
|
||||||
return false;
|
&& tox_event_data_unpack(event->type, &event->data, bu, mem);
|
||||||
}
|
|
||||||
|
|
||||||
if (size != 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tox_Event_Type type;
|
|
||||||
if (!tox_event_type_unpack(bu, &type)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
event->type = type;
|
|
||||||
|
|
||||||
return tox_event_data_unpack(event->type, &event->data, bu, mem);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ bool tox_events_get_bytes(const Tox_Events *events, uint8_t *bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
static bool tox_events_unpack(void *obj, Bin_Unpack *bu)
|
static bool tox_events_unpack_handler(void *obj, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
Tox_Events *events = (Tox_Events *)obj;
|
Tox_Events *events = (Tox_Events *)obj;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ Tox_Events *tox_events_load(const Tox_System *sys, const uint8_t *bytes, uint32_
|
||||||
};
|
};
|
||||||
events->mem = sys->mem;
|
events->mem = sys->mem;
|
||||||
|
|
||||||
if (!bin_unpack_obj(tox_events_unpack, events, bytes, bytes_size)) {
|
if (!bin_unpack_obj(tox_events_unpack_handler, events, bytes, bytes_size)) {
|
||||||
tox_events_free(events);
|
tox_events_free(events);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user