GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72086
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
create.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <grass/btree.h>
4 
5 int btree_create(BTREE * B, int (*cmp) (const void *, const void *), int incr)
6 {
7  if (incr <= 0)
8  incr = 1;
9 
10  B->N = 0;
11  B->cur = 0;
12  B->tlen = B->incr = incr;
13 
14  /* must have at least 2 nodes, since node[0] is never used */
15  if (B->tlen == 1)
16  B->tlen = 2;
17 
18  B->cmp = cmp;
19  B->node = (BTREE_NODE *) malloc(B->tlen * sizeof(BTREE_NODE));
20  if (B->node == NULL)
21  return 0;
22  return 1;
23 }
int cur
Definition: btree.h:18
int N
Definition: btree.h:16
int incr
Definition: btree.h:17
#define NULL
Definition: ccmath.h:32
void * malloc(YYSIZE_T)
int(* cmp)(const void *, const void *)
Definition: btree.h:19
Definition: btree.h:12
BTREE_NODE * node
Definition: btree.h:14
int tlen
Definition: btree.h:15
int btree_create(BTREE *B, int(*cmp)(const void *, const void *), int incr)
Definition: create.c:5