1 /*
2  * fiked - a fake IKE PSK+XAUTH daemon based on vpnc
3  * Copyright (C) 2005, Daniel Roethlisberger <daniel@roe.ch>
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, see http://www.gnu.org/copyleft/
17  *
18  * $Id: mem.c 103 2005-12-18 16:28:08Z roe $
19  */
20 
21 #include "mem.h"
22 #include <stdlib.h>
23 
mem_free(void * memptr)24 inline void mem_free(void *memptr)
25 {
26 	if(*(void**)memptr) {
27 		free(*(void**)memptr);
28 		*(void**)memptr = NULL;
29 	}
30 }
31 
mem_allocate(void * memptr,size_t size)32 inline void mem_allocate(void *memptr, size_t size)
33 {
34 	mem_free(memptr);
35 	*(void**)memptr = malloc(size);
36 	if(!*(void**)memptr)
37 		abort();
38 }
39 
40