diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
| commit | 73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch) | |
| tree | e299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/tinyprintf/heap/add.c | |
| parent | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff) | |
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/tinyprintf/heap/add.c')
| -rw-r--r-- | rushs/tinyprintf/heap/add.c | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/rushs/tinyprintf/heap/add.c b/rushs/tinyprintf/heap/add.c deleted file mode 100644 index 78a4db8..0000000 --- a/rushs/tinyprintf/heap/add.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdlib.h> - -#include "heap.h" - -void heapify(int arr[], int n, int i) -{ - if (i == 0) - return; - int parent = (i - 1) / 2; - if (parent >= 0) - { - if (arr[i] > arr[parent]) - { - int tmp = arr[i]; - arr[i] = arr[parent]; - arr[parent] = tmp; - heapify(arr, n, parent); - } - } -} - -void add(struct heap *heap, int val) -{ - if (heap->size == heap->capacity) - { - heap->array = realloc(heap->array, heap->capacity * 2 * sizeof(int)); - if (heap->array == NULL) - { - free(heap); - return; - } - heap->capacity *= 2; - } - - heap->array[heap->size] = val; - heap->size++; - - heapify(heap->array, heap->size, heap->size - 1); -} |
