hi
im trying to browse a tree-structure within my prog. the function i implemented to do this gets a treepointer and a path and returns a node-pointer. with the first call everything is fine, but being a recursive function, the second call fails with a segmentation fault at the call of [memcpy].
this is how my method looks like:
pSceneGraph
findSceneGraphNode(pSceneGraph root, char* objectname){
pSceneGraph tempSceneGraph =malloc(sizeof(struct sceneGraph));
char* sub_string;
char* rest_string;
memcpy ( sub_string, objectname, 50*sizeof(char) );
rest_string=strchr(objektname,'/');
strtok(sub_string,"/");
if (!isEmpty(root) && (sub_string!=NULL)){
if (strcmp(sub_string,root->object.name)==0){
if (rest_string!=NULL){
++*rest_string;
return findSceneGraphNode(root->child,rest_string);
}
return root;
}
return findSceneGraphNode(root->next,objectname);
}
return (pSceneGraph) 0;
}
any ideas?
thanks for any suggestions
martin