se io ho una struttura di questo tipo:

codice:
struct node {
	char *name;
	list children;
	node_type type;    // node_type è un enum
	int id;
};

typedef struct node *node;
e devo fare una funzione che crea un nuovo oggetto di tipo node, di cui ho il prototipo obligato così:

int new_text_node(node *n, char *text, int x);

io l'ho fatta in questo modo:

codice:
int new_text_node(node *n, char *text, int x) {
	node t = malloc(sizeof(struct node));
	node t;
	t->id = x;
	t->name = (char *)malloc(sizeof(char) * strlen(text) + 1);
	strcpy(t->name,text);
	t->type = TEXT_NODE;
	t->children = NULL;
	*n = t;
	return 0;
}
ma mi chiedo, l'allocazione di memoria per il nodo t, va fatta o non va fatta? ho provato in tutte e due i modi, e funziona in entrambe le situazioni...ma una delle due evidentemente sarà sagliata...