list.c merge sort.
[cantaveria.git] / util.h
blob00cee724a4ceabcd0737734a9a48b766b8e8ac8d
1 /*
2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 2010 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 typedef unsigned long utf32;
25 void report_error(const char* format, ...);
26 void fatal_error(const char* format, ...);
27 void out_of_memory(const char*);
29 void* xmalloc(size_t size);
30 char* strxcpy(const char* str);
31 void strmcat(char* dst, const char* src, size_t n);
33 int unicode_getc(char* str, utf32* u);
35 void rand_reset(unsigned s);
36 int randi(int a, int b);
37 double randf();
39 int gcd(int u, int v);
41 typedef struct treenode treenode;
42 struct treenode {
43 treenode* l;
44 treenode* r;
45 void* key;
46 void* value;
49 void tree_insert(
50 treenode* root,
51 int (*compare)(void* k1, void* k2),
52 void* key,
53 void* value
56 void* tree_search(
57 treenode* root,
58 int (*compare)(void* k1, void* k2),
59 void* key