actube/src/cw/intavltree.c
7u83@mail.ru f4ebe841a5 renamed capwap directory to cw.
FossilOrigin-Name: 8a43dd9d05a4cb73210243ddd8df2a26f16c7ef2c4d4e36ab446de1f65d88223
2016-03-03 19:46:20 +00:00

36 lines
439 B
C

#include <stdlib.h>
#include "intavltree.h"
static int cmp(const void *v1,const void*v2)
{
return *((int*)v1) - *((int*)v2);
}
static void del(void* d)
{
free (d);
return;
}
struct mavl * intavltree_create()
{
return mavl_create(cmp,del);
}
int * intavltree_add(struct mavl * t, int val)
{
int *v = mavl_get(t,&val);
if (v)
return v;
v = malloc(sizeof(int));
if (!v)
return NULL;
*v=val;
return mavl_add(t,v);
}