1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-12-22 15:51:11 +00:00

Petite optimisation

This commit is contained in:
Antoine Bartuccio 2018-06-06 20:33:34 +02:00
parent 8ed34b4593
commit 027f2bcc15
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 2 additions and 5 deletions

View File

@ -17,8 +17,7 @@ void _free__Resident(THIS(Resident)){
Resident *_init_Resident(int id, char* name, int apartment_floor){
Resident * new_resident = malloc_or_die(sizeof(Resident));
new_resident->name = malloc_or_die(sizeof(char) * strlen(name));
strcpy(new_resident->name, name);
new_resident->name = strdup(name);
new_resident->id = id;
new_resident->apartment_floor = apartment_floor;
new_resident->position = new_resident->apartment_floor;

View File

@ -16,9 +16,7 @@ void _free__Visitor(THIS(Visitor)){
Visitor *_init_Visitor(int id, char* name){
Visitor * new_visitor = malloc_or_die(sizeof(Visitor));
size_t len = strlen(name);
new_visitor->name = malloc_or_die(sizeof(char) * len);
strcpy(new_visitor->name, name);
new_visitor->name = strdup(name);
new_visitor->id = id;
new_visitor->contact_id = -1;
new_visitor->position = 0;