I need to do an in deep copy of a struct but I cant have distinct pointers for both my variables... here's some of the code:
Code:
TypeEl copieCarte(TypeEl e1, int *err)
{
TypeEl e2;
e2 = initTypeEl(compareCarte,
copieCarte,
getValueCarte,
setValueCarte,
detruireCarte,
err);
e2.el = (Carte *)malloc(sizeof(Carte));
if( e1.copie != copieCarte ) *err = NI;
else if( e2.el == NULL ) *err = NEM;
else
{
*err = OK;
e2.el = e1.el;
}
return e2;
}
The structs referring to that code:
typedef enum {CHAR, INT, UNSIGNED, LONG, FLOAT, DOUBLE, LDOUBLE, STRING, OTHER} Types;
typedef struct sTypeEl TypeEl;
struct sTypeEl
{
void *el;
int (*compare)(TypeEl, TypeEl, int * err);
struct sTypeEl (*copie)(TypeEl, int *err);
Types (*getValue)(TypeEl, void *e, int *err);
Types (*setValue)(TypeEl *,void *e, int *err);
struct sTypeEl (*detruire)(TypeEl, int *err);
};
typedef struct
{
Kind kind;
Value value;
}Carte;
Any help/thoughts would be apreciated
thx