No. Since you do not know the type that the void* points to, a deep copy is out of the question.
In addition, you could not even deep copy a
since it may point to either a single int
ot an array of them.
Typically in C, you would have a structure which carries the data types of it's contents if you wished to be able to do deep copies. For example:
struct teststruct {
int a_sz;
enum voidType vt;
int *a;
void *data;
};
Then you could use a_sz
to figure out how many integers the memory pointed to by a
was composed of and the enumerated type of data
, although technically it could also be an array so you may need a d_sz
as well.
Another trick is to have data
point to a structure that carries it's own data type embedded in it, such as:
typedef struct {
enum voidType vt;
union {
int i;
float f;
double d;
}
} tVoidType;