Debian Codegraph @

texk/web2c/luatexdir/utils/avlstuff.c

raw
1 /*
2
3 Copyright 1996-2006 Han The Thanh <[email protected]>
4 Copyright 2006-2009 Taco Hoekwater <[email protected]>
5
6 This file is part of LuaTeX.
7
8 LuaTeX is free software; you can redistribute it and/or modify it under the terms
9 of the GNU General Public License as published by the Free Software Foundation;
10 either version 2 of the License, or (at your option) any later version.
11
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along with
17 LuaTeX; if not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "ptexlib.h"
22 #include "utils/avl.h"
23
24 /*tex
25
26 Some memory management functions for AVL.
27
28 */
29
30 static void *avl_xmalloc(struct libavl_allocator *allocator, size_t size)
31 {
32 assert(allocator != NULL && size > 0);
33 return xmalloc((unsigned) size);
34 }
35
36 static void avl_xfree(struct libavl_allocator *allocator, void *block)
37 {
38 assert(allocator != NULL && block != NULL);
39 xfree(block);
40 }
41
42 struct libavl_allocator avl_xallocator = {
43 avl_xmalloc,
44 avl_xfree
45 };
46
47 /*tex
48
49 The general AVL comparison functions.
50
51 */
52 int comp_int_entry(const void *pa, const void *pb, void *p)
53 {
54 (void) p;
55 cmp_return(*(const int *) pa, *(const int *) pb);
56 return 0;
57 }
58
59 int comp_string_entry(const void *pa, const void *pb, void *p)
60 {
61 (void) p;
62 return strcmp((const char *) pa, (const char *) pb);
63 }