Skip to content

Commit 6aa9e68

Browse files
committed
cleanup: Minor cleanup of event unpack code.
1 parent bdf460a commit 6aa9e68

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
48ed699a0da0282b7e12142648a322198a2f2af791df3fb49bbe3f7e41afadc4 /usr/local/bin/tox-bootstrapd
1+
7dfcf534fb80fbd8337337f5aa9eaa120febc72386046c7ab0d5c7545e900657 /usr/local/bin/tox-bootstrapd

toxcore/tox_event.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
940940
}
941941

942942
non_null()
943-
static bool tox_event_type_unpack(Bin_Unpack *bu, Tox_Event_Type *val)
943+
static bool tox_event_type_unpack(Tox_Event_Type *val, Bin_Unpack *bu)
944944
{
945945
uint32_t u32;
946946
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
10801080

10811081
bool tox_event_unpack_into(Tox_Event *event, Bin_Unpack *bu, const Memory *mem)
10821082
{
1083-
uint32_t size;
1084-
if (!bin_unpack_array(bu, &size)) {
1085-
return false;
1086-
}
1087-
1088-
if (size != 2) {
1089-
return false;
1090-
}
1091-
1092-
Tox_Event_Type type;
1093-
if (!tox_event_type_unpack(bu, &type)) {
1094-
return false;
1095-
}
1096-
1097-
event->type = type;
1098-
1099-
return tox_event_data_unpack(event->type, &event->data, bu, mem);
1083+
return bin_unpack_array_fixed(bu, 2, nullptr) //
1084+
&& tox_event_type_unpack(&event->type, bu) //
1085+
&& tox_event_data_unpack(event->type, &event->data, bu, mem);
11001086
}

toxcore/tox_events.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool tox_events_get_bytes(const Tox_Events *events, uint8_t *bytes)
134134
}
135135

136136
non_null()
137-
static bool tox_events_unpack(void *obj, Bin_Unpack *bu)
137+
static bool tox_events_unpack_handler(void *obj, Bin_Unpack *bu)
138138
{
139139
Tox_Events *events = (Tox_Events *)obj;
140140

@@ -174,7 +174,7 @@ Tox_Events *tox_events_load(const Tox_System *sys, const uint8_t *bytes, uint32_
174174
};
175175
events->mem = sys->mem;
176176

177-
if (!bin_unpack_obj(tox_events_unpack, events, bytes, bytes_size)) {
177+
if (!bin_unpack_obj(tox_events_unpack_handler, events, bytes, bytes_size)) {
178178
tox_events_free(events);
179179
return nullptr;
180180
}

0 commit comments

Comments
 (0)