ReactOS
0.4.15-dev-5615-gc3644fd
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
}
realloc
#define realloc
Definition:
debug_ros.c:6
strerror
const char * strerror(int errnum)
Definition:
compat_str.c:23
strlen
ACPI_SIZE strlen(const char *String)
Definition:
utclib.c:269
safe_realloc
void * safe_realloc(void *ptr, size_t size)
Definition:
compat_str.c:16
sys_nerr
int sys_nerr
compat_strdup
char * compat_strdup(const char *src)
Definition:
compat_str.c:32
ptr
static PVOID ptr
Definition:
dispmode.c:27
size
GLsizeiptr size
Definition:
glext.h:5919
memcpy
#define memcpy(s1, s2, n)
Definition:
mkisofs.h:878
len
GLenum GLsizei len
Definition:
glext.h:6722
src
GLenum src
Definition:
glext.h:6340
sys_errlist
char * sys_errlist[]
NULL
#define NULL
Definition:
types.h:112
malloc
#define malloc
Definition:
debug_ros.c:4
dest
static char * dest
Definition:
rtl.c:135
sdk
lib
3rdparty
libmpg123
compat
compat_str.c
Generated on Mon Jan 30 2023 06:07:40 for ReactOS by
1.8.15