ReactOS
0.4.15-dev-8636-g945e856
mem.c
Go to the documentation of this file.
1
/* @(#)mem.c 1.11 15/05/10 Copyright 1998-2015 J. Schilling */
2
#include <
schily/mconfig.h
>
3
#ifndef lint
4
static
UConst
char
sccsid
[] =
5
"@(#)mem.c 1.11 15/05/10 Copyright 1998-2015 J. Schilling"
;
6
#endif
7
/*
8
* Memory handling with error checking
9
*
10
* Copyright (c) 1998-2015 J. Schilling
11
*/
12
/*
13
* The contents of this file are subject to the terms of the
14
* Common Development and Distribution License, Version 1.0 only
15
* (the "License"). You may not use this file except in compliance
16
* with the License.
17
*
18
* See the file CDDL.Schily.txt in this distribution for details.
19
* A copy of the CDDL is also available via the Internet at
20
* http://www.opensource.org/licenses/cddl1.txt
21
*
22
* When distributing Covered Code, include this CDDL HEADER in each
23
* file and include the License file CDDL.Schily.txt from this distribution.
24
*/
25
26
#include <
schily/stdio.h
>
27
#include <
schily/stdlib.h
>
28
#include <
schily/unistd.h
>
29
#include <
schily/string.h
>
30
#include <
schily/standard.h
>
31
#include <
schily/schily.h
>
32
#include <
schily/nlsdefs.h
>
33
34
EXPORT
int
___mexval
__PR
((
int
exval));
35
EXPORT
void
*
___malloc
__PR
((
size_t
size
,
char
*
msg
));
36
EXPORT
void
*
___realloc
__PR
((
void
*
ptr
,
size_t
size
,
char
*
msg
));
37
EXPORT
char
*
___savestr
__PR
((
const
char
*
s
));
38
39
LOCAL
int
mexval
;
40
41
EXPORT
int
42
___mexval
(exval)
43
int
exval;
44
{
45
int
ret
=
mexval
;
46
47
mexval
= exval;
48
49
return
(
ret
);
50
}
51
52
EXPORT
void
*
53
___malloc
(
size
,
msg
)
54
size_t
size
;
55
char
*
msg
;
56
{
57
void
*
ret
;
58
59
ret
=
malloc
(
size
);
60
if
(
ret
==
NULL
) {
61
int
err
=
geterrno
();
62
63
errmsg
(
gettext
(
"Cannot allocate memory for %s.\n"
),
msg
);
64
if
(
mexval
)
65
err
=
mexval
;
66
comexit
(
err
);
67
/* NOTREACHED */
68
}
69
return
(
ret
);
70
}
71
72
EXPORT
void
*
73
___realloc
(
ptr
,
size
,
msg
)
74
void
*
ptr
;
75
size_t
size
;
76
char
*
msg
;
77
{
78
void
*
ret
;
79
80
if
(
ptr
==
NULL
)
81
ret
=
malloc
(
size
);
82
else
83
ret
=
realloc
(
ptr
,
size
);
84
if
(
ret
==
NULL
) {
85
int
err
=
geterrno
();
86
87
errmsg
(
gettext
(
"Cannot realloc memory for %s.\n"
),
msg
);
88
if
(
mexval
)
89
err
=
mexval
;
90
comexit
(
err
);
91
/* NOTREACHED */
92
}
93
return
(
ret
);
94
}
95
96
EXPORT
char
*
97
___savestr
(
s
)
98
const
char
*
s
;
99
{
100
char
*
ret
=
___malloc
(
strlen
(
s
)+1,
"saved string"
);
101
102
strcpy
(
ret
,
s
);
103
return
(
ret
);
104
}
strlen
ACPI_SIZE strlen(const char *String)
Definition:
utclib.c:269
strcpy
char * strcpy(char *DstString, const char *SrcString)
Definition:
utclib.c:388
msg
#define msg(x)
Definition:
auth_time.c:54
UConst
#define UConst
Definition:
ccomdefs.h:72
comexit
EXPORT void comexit(int err)
Definition:
comerr.c:331
errmsg
EXPORT int errmsg(char *msg, va_alist)
Definition:
comerr.c:192
realloc
#define realloc
Definition:
debug_ros.c:6
malloc
#define malloc
Definition:
debug_ros.c:4
NULL
#define NULL
Definition:
types.h:112
geterrno
EXPORT int geterrno()
Definition:
geterrno.c:34
s
GLdouble s
Definition:
gl.h:2039
size
GLsizeiptr size
Definition:
glext.h:5919
LOCAL
#define LOCAL(type)
Definition:
jmorecfg.h:289
mconfig.h
ptr
static PVOID ptr
Definition:
dispmode.c:27
nlsdefs.h
gettext
#define gettext(s)
Definition:
nlsdefs.h:71
__PR
#define __PR(a)
Definition:
prototyp.h:106
err
#define err(...)
Definition:
reactos_support_code.h:30
schily.h
___realloc
#define ___realloc
Definition:
schily.h:631
___mexval
#define ___mexval
Definition:
schily.h:629
___malloc
#define ___malloc
Definition:
schily.h:630
___savestr
#define ___savestr
Definition:
schily.h:632
string.h
sccsid
static UConst char sccsid[]
Definition:
mem.c:4
mexval
LOCAL int mexval
Definition:
mem.c:39
standard.h
EXPORT
Definition:
spec2def.c:21
stdio.h
stdlib.h
unistd.h
ret
int ret
Definition:
wcstombs-tests.c:31
sdk
tools
mkisofs
schilytools
libschily
mem.c
Generated on Tue Sep 10 2024 06:14:27 for ReactOS by
1.9.6