void*
SFSFindDataOrSave(SFSTree *info, SFSDataIO *in, SFSTreePosition *position) {
if ( position )
- memset(position, 0, sizeof(position));
+ memset(position, 0, sizeof(SFSTreePosition));
return SFSFindDataFromSavedOrSave(info, in, position);
}
return NULL;
else if ( STRNCMP(ptr, ((char*)node)+node->dataptr, node->nchar) ) {
ptr+=node->nchar;
- if ( ISEND(ptr, in->key, in->keylen) && node->isword) {
- return (void*) ( ((char*)(node->data)) + ((node->haschild) ? sizeof(SFSNode*) : 0) );
+ if ( ISEND(ptr, in->key, in->keylen) ) {
+ if (node->isword)
+ return (void*) ( ((char*)(node->data)) + ((node->haschild) ? sizeof(SFSNode*) : 0) );
+ return NULL;
} else if ( node->haschild ) {
- node = getSkipChildPointer(info, node);
pnode = (SFSNode**)( (char*)(node->data) );
+ node = getSkipChildPointer(info, node);
} else {
return NULL;
}
StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
if ( StopMiddle->val == *ptr ) {
ptr++;
- if ( ISEND(ptr, in->key, in->keylen) && StopMiddle->isword ) {
- return (void*)( ((char*)node) + node->dataptr + info->datasize * StopMiddle->data );
+ if ( ISEND(ptr, in->key, in->keylen) ) {
+ if ( StopMiddle->isword )
+ return (void*)( ((char*)node) + node->dataptr + info->datasize * StopMiddle->data );
+ return NULL;
} else if ( StopMiddle->haschild ) {
- node = getChildPointer(info, StopMiddle);
pnode = (SFSNode**)(((char*)StopMiddle) + StopMiddle->child);
+ node = getChildPointer(info, StopMiddle);
} else {
return NULL;
}
SFSAddSaved(SFSTree *info, SFSDataIO *in, SFSTreePosition *position) {
CHECK_MEMORY(info);
- if ( !(position->nodeptr && position->node) ) {
+ if ( !(position && position->nodeptr && position->node) ) {
SFSAdd(info, in);
return;
}