I am trying to change the size of the array from another function. The code compiles but the program crashes... I am stuck, very stuck. New to this, my head is spinning up down left right aaaaah........
array.c
struct array {
    int* data;
    int size;
};
struct array* array_create()
{
    struct array* array = (struct array*) malloc(sizeof(struct array));
    array->data = (int*) malloc(sizeof(int) * 10000);
    array->size = 10000;
    return array;
}
void array_resize(struct array* array, int size)
{
    if (size > array->size) {
        free(array);
        array->data = (int*) malloc(sizeof(int) * size);
    }
    array->size = size;
}
int array_size(struct array* array)
{
    return array->size;
}
array.h
typedef struct array* ARRAY;
ARRAY array_create();
void array_resize(struct array* array, int size);
edit.c
void edit()
{
    array_resize(array, 100); // I can run the code but program crashes
}
main.c
ARRAY array;
array = array_create();
edit();                       // Program crashes
 
     
    