diff options
| -rw-r--r-- | allocator.h | 5 | ||||
| -rw-r--r-- | arraylist.c | 8 | ||||
| -rw-r--r-- | queue.c | 2 | ||||
| -rw-r--r-- | rb.c | 4 | ||||
| -rw-r--r-- | ringbuff.c | 6 | ||||
| -rw-r--r-- | stack.c | 2 | ||||
| -rw-r--r-- | stack2.c | 4 | ||||
| -rw-r--r-- | tree.c | 4 |
8 files changed, 13 insertions, 22 deletions
diff --git a/allocator.h b/allocator.h index fc28833..d47af52 100644 --- a/allocator.h +++ b/allocator.h | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | #ifndef ITS1_ALLOCATOR_H_INCLUDED | 1 | #pragma once |
| 2 | #define ITS1_ALLOCATOR_H_INCLUDED | ||
| 3 | 2 | ||
| 4 | #include <stddef.h> /* size_t */ | 3 | #include <stddef.h> /* size_t */ |
| 5 | 4 | ||
| @@ -29,5 +28,3 @@ void *its1_malloc_zero(struct its1_allocator *allocator, size_t n); | |||
| 29 | 28 | ||
| 30 | #define NEW(ptr) ((ptr) = ALLOCATE(sizeof *(ptr))) | 29 | #define NEW(ptr) ((ptr) = ALLOCATE(sizeof *(ptr))) |
| 31 | #define NEW0(ptr) ((ptr) = ALLOCATE_ZERO(sizeof *(ptr))) | 30 | #define NEW0(ptr) ((ptr) = ALLOCATE_ZERO(sizeof *(ptr))) |
| 32 | |||
| 33 | #endif | ||
diff --git a/arraylist.c b/arraylist.c index cb23e94..f010d07 100644 --- a/arraylist.c +++ b/arraylist.c | |||
| @@ -115,7 +115,7 @@ ArrayList_insertAt(struct ArrayList *arrayList, size_t idx, T *ptr) | |||
| 115 | 115 | ||
| 116 | memmove(&arrayList->array[idx + 1], | 116 | memmove(&arrayList->array[idx + 1], |
| 117 | &arrayList->array[idx], | 117 | &arrayList->array[idx], |
| 118 | (arrayList->size - idx) * sizeof(arrayList->array[0])); | 118 | (arrayList->size - idx) * sizeof arrayList->array[0]); |
| 119 | arrayList->array[idx] = ptr; | 119 | arrayList->array[idx] = ptr; |
| 120 | ++arrayList->size; | 120 | ++arrayList->size; |
| 121 | } | 121 | } |
| @@ -158,7 +158,7 @@ ArrayList_removeAt(struct ArrayList *arrayList, size_t idx, void clear_func(T *, | |||
| 158 | #if defined(ARRAYLIST_KEEP_ORDER) | 158 | #if defined(ARRAYLIST_KEEP_ORDER) |
| 159 | memmove(&arrayList->arrayList[idx], | 159 | memmove(&arrayList->arrayList[idx], |
| 160 | &arrayList->arrayList[idx + 1], | 160 | &arrayList->arrayList[idx + 1], |
| 161 | (arrayList->size - (idx + 1)) * sizeof(arrayList->arrayList[0])); | 161 | (arrayList->size - (idx + 1)) * sizeof arrayList->arrayList[0]); |
| 162 | #else | 162 | #else |
| 163 | arrayList->array[idx] = arrayList->array[arrayList->size - 1]; | 163 | arrayList->array[idx] = arrayList->array[arrayList->size - 1]; |
| 164 | #endif | 164 | #endif |
| @@ -196,7 +196,7 @@ ArrayList_sort(struct ArrayList *arrayList, int cmp(const T *, const T *, void * | |||
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | // Das vollständige qsort_x()-Drama: https://stackoverflow.com/a/46042467 | 198 | // Das vollständige qsort_x()-Drama: https://stackoverflow.com/a/46042467 |
| 199 | qsort_r(arrayList->array, arrayList->size, sizeof(arrayList->array[0]), &context, ArrayList_qsortHelper); | 199 | qsort_r(arrayList->array, arrayList->size, sizeof arrayList->array[0], &context, ArrayList_qsortHelper); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | bool | 202 | bool |
| @@ -243,7 +243,7 @@ ArrayList_binarySearch(struct ArrayList *arrayList, void *key, int cmp(void *, c | |||
| 243 | .args = args | 243 | .args = args |
| 244 | }; | 244 | }; |
| 245 | 245 | ||
| 246 | T **pos = bsearch(&context, arrayList->array, arrayList->size, sizeof(arrayList->array[0]), ArrayList_bsearchHelper); | 246 | T **pos = bsearch(&context, arrayList->array, arrayList->size, sizeof arrayList->array[0], ArrayList_bsearchHelper); |
| 247 | if ( pos ) { | 247 | if ( pos ) { |
| 248 | *loc = (size_t)(pos - arrayList->array); | 248 | *loc = (size_t)(pos - arrayList->array); |
| 249 | return true; | 249 | return true; |
| @@ -33,7 +33,7 @@ queue_put(struct queue *queue, T data) | |||
| 33 | { | 33 | { |
| 34 | struct queue_item *new_item; | 34 | struct queue_item *new_item; |
| 35 | 35 | ||
| 36 | if ( (new_item = malloc(sizeof(*new_item))) != NULL ) { | 36 | if ( (new_item = malloc(sizeof *new_item)) != NULL ) { |
| 37 | struct queue_item *tmp = queue->tail; | 37 | struct queue_item *tmp = queue->tail; |
| 38 | new_item->data = data; | 38 | new_item->data = data; |
| 39 | new_item->next = NULL; | 39 | new_item->next = NULL; |
| @@ -189,7 +189,7 @@ verify_property_5_helper(node n, int black_count, int *path_black_count) | |||
| 189 | rbtree | 189 | rbtree |
| 190 | rbtree_create() | 190 | rbtree_create() |
| 191 | { | 191 | { |
| 192 | rbtree t = malloc(sizeof(struct rbtree_t)); | 192 | rbtree t = malloc(sizeof *t); |
| 193 | t->root = NULL; | 193 | t->root = NULL; |
| 194 | verify_properties(t); | 194 | verify_properties(t); |
| 195 | return t; | 195 | return t; |
| @@ -198,7 +198,7 @@ rbtree_create() | |||
| 198 | node | 198 | node |
| 199 | new_node(void *key, void *value, color node_color, node left, node right) | 199 | new_node(void *key, void *value, color node_color, node left, node right) |
| 200 | { | 200 | { |
| 201 | node result = malloc(sizeof(struct rbtree_node_t)); | 201 | node result = malloc(sizeof *result); |
| 202 | result->key = key; | 202 | result->key = key; |
| 203 | result->value = value; | 203 | result->value = value; |
| 204 | result->color = node_color; | 204 | result->color = node_color; |
| @@ -107,12 +107,6 @@ ring_get(struct ring_buffer *rb, T *data) | |||
| 107 | /* -->8-- */ | 107 | /* -->8-- */ |
| 108 | 108 | ||
| 109 | void | 109 | void |
| 110 | f() | ||
| 111 | { | ||
| 112 | ERROR(""); | ||
| 113 | } | ||
| 114 | |||
| 115 | void | ||
| 116 | debug_print(const char *msg, struct ring_buffer *rb) | 110 | debug_print(const char *msg, struct ring_buffer *rb) |
| 117 | { | 111 | { |
| 118 | printf("%s: head: %zu, tail: %zu\n", msg, rb->head, rb->tail); | 112 | printf("%s: head: %zu, tail: %zu\n", msg, rb->head, rb->tail); |
| @@ -33,7 +33,7 @@ stack_push(struct stack *stack, T data) | |||
| 33 | { | 33 | { |
| 34 | struct stack_item *new_item; | 34 | struct stack_item *new_item; |
| 35 | 35 | ||
| 36 | if ( (new_item = malloc(sizeof(*new_item))) != NULL ) { | 36 | if ( (new_item = malloc(sizeof *new_item)) != NULL ) { |
| 37 | new_item->data = data; | 37 | new_item->data = data; |
| 38 | new_item->next = stack->head; | 38 | new_item->next = stack->head; |
| 39 | stack->head = new_item; | 39 | stack->head = new_item; |
| @@ -28,7 +28,7 @@ bool | |||
| 28 | stack_push(struct stack *stack, T data) | 28 | stack_push(struct stack *stack, T data) |
| 29 | { | 29 | { |
| 30 | if ( stack->array == NULL ) { | 30 | if ( stack->array == NULL ) { |
| 31 | if ( (stack->array = malloc(10 * sizeof(*stack->array))) != NULL ) { | 31 | if ( (stack->array = malloc(10 * sizeof *stack->array)) != NULL ) { |
| 32 | stack->sz = 10; | 32 | stack->sz = 10; |
| 33 | stack->p = 0; | 33 | stack->p = 0; |
| 34 | } | 34 | } |
| @@ -42,7 +42,7 @@ stack_push(struct stack *stack, T data) | |||
| 42 | size_t new_sz; | 42 | size_t new_sz; |
| 43 | T * new_array; | 43 | T * new_array; |
| 44 | 44 | ||
| 45 | if ( (new_array = realloc(stack->array, (new_sz = (stack->sz * 3 / 2)) * sizeof(*stack->array))) != NULL ) { | 45 | if ( (new_array = realloc(stack->array, (new_sz = (stack->sz * 3 / 2)) * sizeof *stack->array)) != NULL ) { |
| 46 | stack->array = new_array; | 46 | stack->array = new_array; |
| 47 | stack->sz = new_sz; | 47 | stack->sz = new_sz; |
| 48 | } | 48 | } |
| @@ -340,7 +340,7 @@ stack_push(struct stack *stack, struct tree_node *data) | |||
| 340 | { | 340 | { |
| 341 | struct stack_item *new_item; | 341 | struct stack_item *new_item; |
| 342 | 342 | ||
| 343 | if ( (new_item = malloc(sizeof(*new_item))) ) { | 343 | if ( (new_item = malloc(sizeof *new_item)) ) { |
| 344 | new_item->data = data; | 344 | new_item->data = data; |
| 345 | new_item->next = stack->head; | 345 | new_item->next = stack->head; |
| 346 | stack->head = new_item; | 346 | stack->head = new_item; |
| @@ -426,7 +426,7 @@ queue_put(struct queue *queue, struct tree_node *data) | |||
| 426 | { | 426 | { |
| 427 | struct queue_item *new_item; | 427 | struct queue_item *new_item; |
| 428 | 428 | ||
| 429 | if ( (new_item = malloc(sizeof(*new_item))) ) { | 429 | if ( (new_item = malloc(sizeof *new_item)) ) { |
| 430 | struct queue_item *tail; | 430 | struct queue_item *tail; |
| 431 | 431 | ||
| 432 | tail = queue->tail; | 432 | tail = queue->tail; |
