File: ni_malloc.c

package info (click to toggle)
libnet-interface-perl 1.016-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,252 kB
  • ctags: 478
  • sloc: ansic: 3,397; sh: 2,736; perl: 888; makefile: 3
file content (83 lines) | stat: -rw-r--r-- 2,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

/* ********************************************************************	*
 * ni_malloc.c	version 0.01 2-11-09					*
 *									*
 *     COPYRIGHT 2008-2009 Michael Robinton <michael@bizsystems.com>	*
 *									*
 * This program is free software; you can redistribute it and/or modify	*
 * it under the terms of either:					*
 *									*
 *  a) the GNU General Public License as published by the Free		*
 *  Software Foundation; either version 2, or (at your option) any	*
 *  later version, or							*
 *									*
 *  b) the "Artistic License" which comes with this distribution.	*
 *									*
 * This program is distributed in the hope that it will be useful,	*
 * but WITHOUT ANY WARRANTY; without even the implied warranty of	*
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either	*
 * the GNU General Public License or the Artistic License for more 	*
 * details.								*
 *									*
 * You should have received a copy of the Artistic License with this	*
 * distribution, in the file named "Artistic".  If not, I'll be glad 	*
 * to provide one.							*
 *									*
 * You should also have received a copy of the GNU General Public 	*
 * License along with this program in the file named "Copying". If not, *
 * write to the 							*
 *									*
 *	Free Software Foundation, Inc.					*
 *	59 Temple Place, Suite 330					*
 *	Boston, MA  02111-1307, USA					*
 *									*
 * or visit their web page on the internet at:				*
 *									*
 *	http://www.gnu.org/copyleft/gpl.html.				*
 * ********************************************************************	*/

#include "config.h"

int __ni_malloc_c_silence_warning;

#if HAVE_MALLOC == 0 || HAVE_REALLOC == 0

/* if this OS has buggy memory allocation, fix it	*/

#warning FUNCTIONS calloc, malloc, realloc, free re-defined because of buggy C lib

#include <sys/types.h>
#include <stdlib.h>

void *
ni_rpl_malloc (size_t n)
{
    if (n == 0)
	n = 1;
    return malloc(n);
}

void *
ni_rpl_calloc (size_t mbsz, size_t n)
{
    if (n == 0)
	n = 1;
    return calloc(mbsz,n);
}

void *
ni_rpl_realloc (void * ptr, size_t n)
{
    if (ptr == NULL)
	return malloc(n);
    return realloc(ptr,n);
}

void
ni_rpl_free  (void * ptr)
{
    if (ptr != NULL)
	free(ptr);
}

#endif