1tst(3)                    InterNetNews Documentation                    tst(3)
2
3
4

NAME

6       tst - ternary search trie functions
7

SYNOPSIS

9       #include <inn/tst.h>
10
11       struct tst;
12
13       struct tst *tst_init(int node_line_width);
14
15       void tst_cleanup(struct tst *tst);
16
17       int tst_insert(struct tst *tst, const unsigned char *key, void *data,
18       int option, void **exist_ptr);
19
20       void *tst_search(struct tst *tst, const unsigned char *key);
21
22       void *tst_delete(struct tst *tst, const unsigned char *key);
23

DESCRIPTION

25       tst_init allocates memory for members of struct tst, and allocates the
26       first node_line_width nodes. A NULL pointer is returned by tst_init if
27       any part of the memory allocation fails. On success, a pointer to a
28       struct tst is returned.
29
30       The value for node_line_width must be chosen very carefully. One node
31       is required for every character in the tree. If you choose a value that
32       is too small, your application will spend too much time calling mal‐
33       loc(3) and your node space will be too spread out. Too large a value is
34       just a waste of space.
35
36       tst_cleanup frees all memory allocated to nodes, internal structures,
37       as well as tst itself.
38
39       tst_insert inserts the string key into the tree. Behavior when a dupli‐
40       cate key is inserted is controlled by option. If key is already in the
41       tree then TST_DUPLICATE_KEY is returned, and the data pointer for the
42       existing key is placed in exist_ptr.  If option is set to TST_REPLACE
43       then the existing data pointer for the existing key is replaced by
44       data.  Note that the old data pointer will still be placed in
45       exist_ptr.
46
47       If a duplicate key is encountered and option is not set to TST_REPLACE
48       then TST_DUPLICATE_KEY is returned. If key is zero length then
49       TST_NULL_KEY is returned. A successful insert or replace returns
50       TST_OK. A return value of TST_ERROR indicates that a memory allocation
51       error occurred while trying to grow the node free.
52
53       Note that the data argument must never be NULL. If it is, then calls to
54       tst_search will fail for a key that exists because the data value was
55       set to NULL, which is what tst_search returns. If you just want a sim‐
56       ple existence tree, use the tst pointer as the data pointer.
57
58       tst_search finds the string key in the tree if it exists and returns
59       the data pointer associated with that key.
60
61       If key is not found then NULL is returned, otherwise the data pointer
62       associated with key is returned.
63
64       tst_delete deletes the string key from the tree if it exists and
65       returns the data pointer assocaited with that key.
66
67       If key is not found then NULL is returned, otherwise the data pointer
68       associated with key is returned.
69

HISTORY

71       Converted to POD from Peter A. Friend's ternary search trie documenta‐
72       tion by Alex Kiernan <alex.kiernan@thus.net> for InterNetNews 2.4.0.
73
74       $Id: tst.3 6106 2003-01-02 12:22:14Z vinocur $
75
76
77
78INN 2.4.0                         2003-01-02                            tst(3)
Impressum