1 /*
2  * Copyright (c) 2014 Hayaki Saito
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "config.h"
19 
20 #if HAVE_ERRNO_H
21 #include <errno.h>
22 #endif  /* HAVE_ERRNO_H */
23 
24 #include <stdlib.h>
25 
26 #if HAVE_MEMORY_H
27 # include <memory.h>
28 #endif  /* HAVE_MEMORY_H */
29 
30 #if !HAVE_MALLOC
31 # undef malloc
32 void *
rpl_malloc(size_t n)33 rpl_malloc(size_t n)
34 {
35     if(n == 0) {
36         n = 1;
37     }
38     return (void *)malloc(n);
39 }
40 #endif /* !HAVE_MALLOC */
41 
42 #if !HAVE_REALLOC
43 # undef realloc
44 void *
rpl_realloc(void * p,size_t n)45 rpl_realloc(void *p, size_t n)
46 {
47     if (n == 0) {
48         n = 1;
49     }
50     if (p == 0) {
51         return malloc(n);
52     }
53     return (void *)realloc(p, n);
54 }
55 #endif /* !HAVE_REALLOC */
56 
57 /* Hello emacs, -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
58 /* vim: set expandtab ts=4 : */
59 /* EOF */
60