A
Alfonso Morra
Hi,
I have the ff data types :
typedef enum {
VAL_LONG ,
VAL_DOUBLE ,
VAL_STRING ,
VAL_DATASET
}ValueTypeEnum ;
typedef union {
long lval ;
double fval ;
char* sval ;
void* ptr ;
} Value ;
typedef struct {
int magic ;
int version ;
}Header ;
typedef struct {
char label[20] ;
id int ;
}Key ;
typedef struct {
Header *hdr ;
char *subject ;
Key key ;
ValueTypeEnum type ;
Value value ;
size_t size ;
}MotherStruct ;
Pseudo code:
=============
MotherStruct *pMS_source = (MotherStruct*)calloc(1, sizeof(MotherStruct));
pMS_source->hdr = CreateHeader();
pMS_source->subject = strdup("Test Subject") ;
pMS_source->key = CreateKey("Test", 2000) ;
pMS_source->type = VAL_STRING ;
pMS_source->value.sval = strdup("Homer Simpson") ;
pMS_source->size = /* How do I calculate this ? */
void MakeMSClone(MotherStruct *pMS_Dest, const MotherStruct *pMS_source) {
memmove(pMS_dest,pMS_source, pMS_Source->size) ;
}
MTIA
I have the ff data types :
typedef enum {
VAL_LONG ,
VAL_DOUBLE ,
VAL_STRING ,
VAL_DATASET
}ValueTypeEnum ;
typedef union {
long lval ;
double fval ;
char* sval ;
void* ptr ;
} Value ;
typedef struct {
int magic ;
int version ;
}Header ;
typedef struct {
char label[20] ;
id int ;
}Key ;
typedef struct {
Header *hdr ;
char *subject ;
Key key ;
ValueTypeEnum type ;
Value value ;
size_t size ;
}MotherStruct ;
Pseudo code:
=============
MotherStruct *pMS_source = (MotherStruct*)calloc(1, sizeof(MotherStruct));
pMS_source->hdr = CreateHeader();
pMS_source->subject = strdup("Test Subject") ;
pMS_source->key = CreateKey("Test", 2000) ;
pMS_source->type = VAL_STRING ;
pMS_source->value.sval = strdup("Homer Simpson") ;
pMS_source->size = /* How do I calculate this ? */
void MakeMSClone(MotherStruct *pMS_Dest, const MotherStruct *pMS_source) {
memmove(pMS_dest,pMS_source, pMS_Source->size) ;
}
MTIA