summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-19 22:15:12 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-21 11:44:58 +0000
commit253abe5de4cc96f767911ede291a341b55e2de0f (patch)
tree05790592c31f317097aa09355753a395d6c773fc
parentc1b7edbed33f3f43e361d256cf7c8a7692d28462 (diff)
Make `resize` in `list.c` return bool instead of 0/1.
-rw-r--r--toxcore/list.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/toxcore/list.c b/toxcore/list.c
index 4846ce25..e4c16054 100644
--- a/toxcore/list.c
+++ b/toxcore/list.c
@@ -29,6 +29,7 @@
29 29
30#include "list.h" 30#include "list.h"
31 31
32#include <stdbool.h>
32#include <stdlib.h> 33#include <stdlib.h>
33#include <string.h> 34#include <string.h>
34 35
@@ -118,23 +119,22 @@ static int find(const BS_List *list, const uint8_t *data)
118 } 119 }
119} 120}
120 121
121/* Resized the list list 122/**
123 * Resizes the list.
122 * 124 *
123 * return value: 125 * @return true on success.
124 * 1 : success
125 * 0 : failure
126 */ 126 */
127static int resize(BS_List *list, uint32_t new_size) 127static bool resize(BS_List *list, uint32_t new_size)
128{ 128{
129 if (new_size == 0) { 129 if (new_size == 0) {
130 bs_list_free(list); 130 bs_list_free(list);
131 return 1; 131 return true;
132 } 132 }
133 133
134 uint8_t *data = (uint8_t *)realloc(list->data, list->element_size * new_size); 134 uint8_t *data = (uint8_t *)realloc(list->data, list->element_size * new_size);
135 135
136 if (!data) { 136 if (!data) {
137 return 0; 137 return false;
138 } 138 }
139 139
140 list->data = data; 140 list->data = data;
@@ -142,12 +142,12 @@ static int resize(BS_List *list, uint32_t new_size)
142 int *ids = (int *)realloc(list->ids, sizeof(int) * new_size); 142 int *ids = (int *)realloc(list->ids, sizeof(int) * new_size);
143 143
144 if (!ids) { 144 if (!ids) {
145 return 0; 145 return false;
146 } 146 }
147 147
148 list->ids = ids; 148 list->ids = ids;
149 149
150 return 1; 150 return true;
151} 151}
152 152
153 153