File: Vmalloc.c

package info (click to toggle)
acm 5.0-19
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,852 kB
  • ctags: 4,792
  • sloc: ansic: 42,427; makefile: 706; cpp: 293; perl: 280; sh: 198
file content (51 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (9)
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

#include "Vlib.h"

#if !HAVE_STDLIB_H
#if HAVE_MALLOC_H
#include <malloc.h>
#else
extern char *malloc();

#endif
#endif

#ifdef WIN32
#undef Vmalloc
#endif

char     *
Vmalloc(int size)
{

	char     *p;

	if ((p = malloc(size)) == (char *) NULL) {
		fprintf(stderr, "V package memory allocation error.\n");
		fprintf(stderr, "An error was encountered allocating\
 %d bytes.\n", size);
		exit(1);
	}
	return p;
}

#ifdef WIN32

#include <crtdbg.h>

char     *
Vmalloc_dbg(int size, const char *file, const int line)
{

	char     *p;

	if ((p = _malloc_dbg(size, _NORMAL_BLOCK, file, line)) == (char *) NULL) {
		fprintf(stderr, "V package memory allocation error.\n");
		fprintf(stderr, "An error was encountered allocating\
 %d bytes.\n", size);
		exit(1);
	}
	return p;
}

#endif