Add more assertions

This commit is contained in:
Patrick Pelissier committed 2020-12-21 15:16:16 +01:00
1 parent ad16b310e1
commit 1671ca8d67
3 files changed
+5 -2

No files matched your search

+2 -2
View File
@@ -373,7 +373,7 @@
M_C(name, _node_list_push_front)(d->list, next); \ M_C(name, _node_list_push_front)(d->list, next); \
} \ } \
n = M_C(name, _node_list_previous_obj)(d->list, n); \ n = M_C(name, _node_list_previous_obj)(d->list, n); \
M_ASSERT (n != NULL); \ M_ASSERT (n != NULL && n->size > 1); \
d->back->node = n; \ d->back->node = n; \
index = n->size-1; \ index = n->size-1; \
} \ } \
@@ -543,7 +543,7 @@
it->deque = d; \ it->deque = d; \
if (M_UNLIKELY (it->index >= it->node->size)) { \ if (M_UNLIKELY (it->index >= it->node->size)) { \
it->node = M_C(name, _node_list_previous_obj)(d->list, it->node); \ it->node = M_C(name, _node_list_previous_obj)(d->list, it->node); \
M_ASSERT (it->node != NULL); \ M_ASSERT (it->node != NULL && it->node->size > 1); \
it->index = it->node->size-1; \ it->index = it->node->size-1; \
} \ } \
} \ } \
+1
View File
@@ -490,6 +490,7 @@
if (M_UNLIKELY (new_size <= old_size)) { \ if (M_UNLIKELY (new_size <= old_size)) { \
M_MEMORY_FULL((size_t)-1); \ M_MEMORY_FULL((size_t)-1); \
} \ } \
M_ASSERT (old_size > 1 && new_size > 1); \
/* Resize the table of the dictionnary */ \ /* Resize the table of the dictionnary */ \
M_C(name, _array_list_pair_resize)(map->table, new_size); \ M_C(name, _array_list_pair_resize)(map->table, new_size); \
/* Move the items to the new upper part */ \ /* Move the items to the new upper part */ \
+2
View File
@@ -826,6 +826,7 @@ stringi_replace_all_str_1ge2 (string_t v, const char str1[], size_t str1len, con
static inline char * static inline char *
stringi_strstr_r(char org[], char src[], const char pattern[], size_t pattern_size) stringi_strstr_r(char org[], char src[], const char pattern[], size_t pattern_size)
{ {
M_ASSERT(pattern_size >= 1);
src -= pattern_size - 1; src -= pattern_size - 1;
while (org <= src) { while (org <= src) {
if (src[0] == pattern[0] if (src[0] == pattern[0]
@@ -1005,6 +1006,7 @@ string_fgets(string_t v, FILE *f, string_fgets_t arg)
retcode = true; /* Something has been read */ retcode = true; /* Something has been read */
// fgets doesn't return the number of characters read, so we need to count. // fgets doesn't return the number of characters read, so we need to count.
size += strlen(&ptr[size]); size += strlen(&ptr[size]);
assert(size >= 1);
if (arg != STRING_READ_FILE && ptr[size-1] == '\n') { if (arg != STRING_READ_FILE && ptr[size-1] == '\n') {
if (arg == STRING_READ_PURE_LINE) { if (arg == STRING_READ_PURE_LINE) {
size --; size --;