push
This commit is contained in:
@@ -36,7 +36,7 @@ struct vector *vector_append(struct vector *v, struct animal *animal){
|
||||
if (v->capacity <= v->size) v = vector_resize(v, v->capacity * 2);
|
||||
// TODO A voir si le realloc ajoute de l'espace a gauche ou a droite
|
||||
// car sinon y a ecrasement de data
|
||||
*(v->animal + (v->capacity - v->size )) = animal;
|
||||
v->animal[v->size] = animal;
|
||||
v->size ++;
|
||||
return v;
|
||||
}
|
||||
@@ -46,10 +46,12 @@ void free_animal(struct animal *animal){
|
||||
if (animal == NULL) return;
|
||||
|
||||
//if(animal->color != NULL) free(animal->color);
|
||||
printf("%s\n",animal->animal.fish->species);
|
||||
printf("%s\n", animal->animal.insect->species);
|
||||
if(animal->type == INSECT) free_insect(animal->animal.insect);
|
||||
if(animal->type == FISH) free_fish(animal->animal.fish);
|
||||
//printf("%s\n",animal->animal.fish->species);
|
||||
//printf("%s\n", animal->animal.insect->species);
|
||||
if(animal->type == INSECT)
|
||||
free_insect(animal->animal.insect);
|
||||
if(animal->type == FISH)
|
||||
free_fish(animal->animal.fish);
|
||||
free(animal->color);
|
||||
free(animal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user