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. */
16void *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
23const 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
32char* 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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const char * strerror(int errnum)
Definition: compat_str.c:23
#define realloc
Definition: debug_ros.c:6
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
#define sys_errlist
Definition: stdlib.h:1346
#define sys_nerr
Definition: stdlib.h:1347
#define compat_strdup
Definition: intsym.h:11
#define safe_realloc
Definition: intsym.h:10
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
static char * dest
Definition: rtl.c:135