#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define IMPLICITNA_VELKOST 10

typedef struct arraylist {
    int * storage;

    int size; /*skutocny pocet prvkov */

    int capacity; /* naalokovana velkost pola */
} arraylist;

arraylist new(void) {
    arraylist list;
    list.size = 0;
    list.storage = calloc(IMPLICITNA_VELKOST, sizeof(int));
    list.capacity = IMPLICITNA_VELKOST;

    return list;
}

int add(arraylist list, int hodnota) {
    if(list.size == list.capacity) {
        printf("Natahujem zoznam");
        list.storage = realloc(list.storage, list.size + IMPLICITNA_VELKOST);
        if(list.storage == NULL) {
            return -1;
        }
        list.capacity = list.size + IMPLICITNA_VELKOST;
    }
    list.storage[list.size] = hodnota;
    list.size++;
}

int main(int argc, char** argv) {
    arraylist zoznam;
    int i = 0;

    zoznam = new();
    for(i = 0; i < 25; i++) {
        add(zoznam, i);
    }
    

    return EXIT_SUCCESS;
}
