mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
style (again)
This commit is contained in:
parent
410294da48
commit
9ae2fde0b9
|
@ -60,6 +60,7 @@ static int find(LIST *list, void *data)
|
|||
|
||||
while (1) {
|
||||
int r = memcmp(data, list->data + list->size * i, list->size);
|
||||
|
||||
if (r == 0) {
|
||||
return list->ids[i];
|
||||
}
|
||||
|
@ -75,6 +76,7 @@ static int find(LIST *list, void *data)
|
|||
}
|
||||
|
||||
delta = (delta) / 2;
|
||||
|
||||
if (delta == 0) {
|
||||
delta = 1;
|
||||
d = 1;
|
||||
|
@ -90,6 +92,7 @@ static int find(LIST *list, void *data)
|
|||
i -= delta;
|
||||
|
||||
delta = (delta) / 2;
|
||||
|
||||
if (delta == 0) {
|
||||
delta = 1;
|
||||
d = 0;
|
||||
|
@ -118,6 +121,7 @@ void list_free(LIST *list)
|
|||
int list_find(LIST *list, void *data)
|
||||
{
|
||||
int r = find(list, data);
|
||||
|
||||
//return only -1 and positive values
|
||||
if (r < 0) {
|
||||
r = -1;
|
||||
|
@ -131,6 +135,7 @@ int list_add(LIST *list, void *data, int id)
|
|||
//find where the new element should be inserted
|
||||
//see: return value of find()
|
||||
int i = find(list, data);
|
||||
|
||||
if (i >= 0) {
|
||||
//already in list
|
||||
return 0;
|
||||
|
@ -142,8 +147,7 @@ int list_add(LIST *list, void *data, int id)
|
|||
list->data = realloc(list->data, list->size * (list->n + 1));
|
||||
list->ids = realloc(list->ids, sizeof(int) * (list->n + 1));
|
||||
|
||||
if(!list->data || !list->ids)
|
||||
{
|
||||
if (!list->data || !list->ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -164,6 +168,7 @@ int list_add(LIST *list, void *data, int id)
|
|||
void list_remove(LIST *list, int id)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < list->n; i++) {
|
||||
if (list->ids[i] == id) {
|
||||
//decrease number of elements
|
||||
|
|
Loading…
Reference in New Issue
Block a user