i have this case where i want to store pointers to structs in some hash table (linked list ) i have :
struct Base {
int age;
};
struct Base *l1 = malloc(sizeof(struct Base ));
l1->age = 20;
now here i stuck somewhere in the code (deep down) i have function which gives me the pointer to Base
callback_(struct Base *l)
{
i don't want to point to l1 which will be gone when the callback ends i want to create new pointer to base which the values of the l1 (age)
struct Base *l2 = ???;
do i need to copy each value ? (deep copy ) in realty there are many members and allot of data so i need something better then deep copy
Aucun commentaire:
Enregistrer un commentaire