Fixed general memory corruption
[middleman.git] / src / mem.c
1 /*
2     MiddleMan filtering proxy server
3     Copyright (C) 2002  Jason McLaughlin
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
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.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20
21 #include <stdlib.h>
22 #include "proto.h"
23
24 /*
25 basic checking for malloc/realloc/free, better to die gracefully than run into problems
26 later on.
27 */
28
29 void *xmalloc(int size)
30 {
31         void *ret;
32
33         ASSERT(size > 0);
34
35         ret = malloc(size);
36
37         ASSERT(ret);
38
39         return ret;
40 }
41
42 void xfree(void *ptr)
43 {
44         ASSERT(ptr);
45
46         free(ptr);
47 }
48
49 void *xrealloc(void *ptr, int newsize)
50 {
51         void *newptr;
52
53         ASSERT(newsize > 0);
54
55         newptr = realloc(ptr, newsize);
56
57         ASSERT(newptr);
58
59         return newptr;
60 }