cleanup: Minor cleanup of event unpack code.

This commit is contained in:
iphydf 2024-01-17 19:46:48 +00:00
parent bdf460a3a9
commit 6aa9e6850d
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 7 additions and 21 deletions

View File

@ -1 +1 @@
48ed699a0da0282b7e12142648a322198a2f2af791df3fb49bbe3f7e41afadc4 /usr/local/bin/tox-bootstrapd
7dfcf534fb80fbd8337337f5aa9eaa120febc72386046c7ab0d5c7545e900657 /usr/local/bin/tox-bootstrapd

View File

@ -940,7 +940,7 @@ static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
}
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;
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)
{
uint32_t size;
if (!bin_unpack_array(bu, &size)) {
return false;
}
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);
return bin_unpack_array_fixed(bu, 2, nullptr) //
&& tox_event_type_unpack(&event->type, bu) //
&& tox_event_data_unpack(event->type, &event->data, bu, mem);
}

View File

@ -134,7 +134,7 @@ bool tox_events_get_bytes(const Tox_Events *events, uint8_t *bytes)
}
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;
@ -174,7 +174,7 @@ Tox_Events *tox_events_load(const Tox_System *sys, const uint8_t *bytes, uint32_
};
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);
return nullptr;
}