GRASS Programmer's Manual  6.4.2(2012)
create.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <grass/btree.h>
00004 
00005 int btree_create(BTREE * B, int (*cmp) (const void *, const void *), int incr)
00006 {
00007     if (incr <= 0)
00008         incr = 1;
00009 
00010     B->N = 0;
00011     B->cur = 0;
00012     B->tlen = B->incr = incr;
00013 
00014     /* must have at least 2 nodes, since node[0] is never used */
00015     if (B->tlen == 1)
00016         B->tlen = 2;
00017 
00018     B->cmp = cmp;
00019     B->node = (BTREE_NODE *) malloc(B->tlen * sizeof(BTREE_NODE));
00020     if (B->node == NULL)
00021         return 0;
00022     return 1;
00023 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines