mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-14 21:03:23 +00:00
34 lines
669 B
C
34 lines
669 B
C
|
//
|
||
|
// Created by Antoine Bartuccio on 06/06/2018.
|
||
|
//
|
||
|
|
||
|
#include "Visitor.h"
|
||
|
#include <string.h>
|
||
|
|
||
|
GETTER(Visitor, char*, name);
|
||
|
GETTER(Visitor, int, id);
|
||
|
|
||
|
void _free__Visitor(THIS(Visitor)){
|
||
|
if (this->name != NULL)
|
||
|
free(this->name);
|
||
|
free(this);
|
||
|
}
|
||
|
|
||
|
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->id = id;
|
||
|
new_visitor->contact_id = -1;
|
||
|
new_visitor->position = 0;
|
||
|
new_visitor->destination = -1;
|
||
|
|
||
|
LINK_ALL(Visitor, new_visitor,
|
||
|
get_name,
|
||
|
get_id
|
||
|
);
|
||
|
|
||
|
return new_visitor;
|
||
|
}
|