actube/src/cw/mavl_replace.c
7u83@mail.ru 4171d208d0 new mavl is working now
FossilOrigin-Name: 65a4eefffea57509c0d7fd573e53b15bf4a730ce297b7db182aaac796ea92448
2018-03-10 23:56:41 +00:00

39 lines
602 B
C

#include "mavl.h"
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;
memcpy(mavlnode_dataptr(node), data, t->data_size);
// return &node->data;
return mavlnode_dataptr(node);
}
return mavl_add(t,data);
*/
}