Exemple #1
0
struct leaf * leaf_ctor(char * name) {
	struct node * super = node_ctor(NULL);
	super->vtable = &leaf_funcs;
	
	struct leaf * this = realloc(super, sizeof(*this));
	this->name = malloc(strlen(name) + 1);
	strcpy(this->name, name);
	
	return this;
}
Exemple #2
0
int create_new_branch(node* end, char* parent, char* nd){
	char* buf_parent = NULL;
	char* buf_nd = NULL;
	node* new_nd = NULL;
	node* new_temp = NULL;
	
	new_nd = node_new();
	new_temp = node_new();
	new_temp -> data = end -> data;
	buf_parent = (char*) calloc (strlen(parent), sizeof(char));
	strcpy(buf_parent, parent);
	node_ctor(buf_parent, end);

	buf_nd = (char*) calloc (strlen(nd), sizeof(char));
	strcpy(buf_nd, nd);
	node_ctor(buf_nd, new_nd);

	add_node_left(end, new_nd);
	add_node_right(end, new_temp);

	return 0;
}