ReactOS
0.4.16-dev-320-g3bd9ddc
compat_str.c
Go to the documentation of this file.
1
/*
2
compat: Some compatibility functions (basic memory and string stuff)
3
4
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
5
So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
6
7
copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1
8
see COPYING and AUTHORS files in distribution or http://mpg123.org
9
initially written by Thomas Orgis, Windows Unicode stuff by JonY.
10
*/
11
12
#include "compat.h"
13
#include "debug.h"
14
15
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
16
void
*
safe_realloc
(
void
*
ptr
,
size_t
size
)
17
{
18
if
(
ptr
==
NULL
)
return
malloc
(
size
);
19
else
return
realloc
(
ptr
,
size
);
20
}
21
22
#ifndef HAVE_STRERROR
23
const
char
*
strerror
(
int
errnum)
24
{
25
extern
int
sys_nerr
;
26
extern
char
*
sys_errlist
[];
27
28
return
(errnum <
sys_nerr
) ?
sys_errlist
[errnum] :
""
;
29
}
30
#endif
31
32
char
*
compat_strdup
(
const
char
*
src
)
33
{
34
char
*
dest
=
NULL
;
35
if
(
src
)
36
{
37
size_t
len
;
38
len
=
strlen
(
src
)+1;
39
if
((
dest
=
malloc
(
len
)))
40
memcpy
(
dest
,
src
,
len
);
41
}
42
return
dest
;
43
}
strlen
ACPI_SIZE strlen(const char *String)
Definition:
utclib.c:269
strerror
const char * strerror(int errnum)
Definition:
compat_str.c:23
realloc
#define realloc
Definition:
debug_ros.c:6
malloc
#define malloc
Definition:
debug_ros.c:4
NULL
#define NULL
Definition:
types.h:112
size
GLsizeiptr size
Definition:
glext.h:5919
src
GLenum src
Definition:
glext.h:6340
len
GLenum GLsizei len
Definition:
glext.h:6722
sys_errlist
#define sys_errlist
Definition:
stdlib.h:1346
sys_nerr
#define sys_nerr
Definition:
stdlib.h:1347
compat_strdup
#define compat_strdup
Definition:
intsym.h:11
safe_realloc
#define safe_realloc
Definition:
intsym.h:10
memcpy
#define memcpy(s1, s2, n)
Definition:
mkisofs.h:878
ptr
static PVOID ptr
Definition:
dispmode.c:27
dest
static char * dest
Definition:
rtl.c:135
sdk
lib
3rdparty
libmpg123
compat
compat_str.c
Generated on Thu Dec 5 2024 06:19:35 for ReactOS by
1.9.6