Booking **bookingSelectPaid(Booking **booking) { Booking **ret = malloc(sizeof(Booking*)); size_t i = 0; int numOfPaid = 0; while (booking[i] != NULL) { if (booking[i]->paid == 1) { ++numOfPaid; size_t newsize = sizeof(Booking*) * (numOfPaid + 1); ret = realloc(ret, newsize); ret[i] = booking[i]; ret[i+1] = NULL; } ++i; } return ret; }