new mavl is working now
FossilOrigin-Name: 65a4eefffea57509c0d7fd573e53b15bf4a730ce297b7db182aaac796ea92448
This commit is contained in:
@ -1,15 +1,38 @@
|
||||
#include "mavl.h"
|
||||
|
||||
union mavldata *mavl_replace(struct mavl *t,void *data){
|
||||
void *mavl_replace(struct mavl *t,const void *data, int * replaced){
|
||||
|
||||
int exists;
|
||||
void * add = mavl_add(t,data,&exists);
|
||||
|
||||
if (replaced != NULL){
|
||||
*replaced = exists;
|
||||
}
|
||||
|
||||
if (!exists){
|
||||
return add;
|
||||
}
|
||||
|
||||
if(t->del){
|
||||
t->del(add);
|
||||
}
|
||||
|
||||
memcpy(add,data,t->data_size);
|
||||
return add;
|
||||
|
||||
/*
|
||||
struct mavlnode * node = mavl_get_node(t,data);
|
||||
if (node){
|
||||
if (t->del)
|
||||
t->del(node+sizeof(struct mavlnode));
|
||||
/* node->data=*data;
|
||||
*/ mavlnode_copy_data(node+sizeof(struct mavlnode), data);
|
||||
return &node->data;
|
||||
// node->data=*data;
|
||||
memcpy(mavlnode_dataptr(node), data, t->data_size);
|
||||
|
||||
// return &node->data;
|
||||
return mavlnode_dataptr(node);
|
||||
}
|
||||
return mavl_add(t,data);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user