ReactOS  0.4.13-dev-482-ge57f103
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 }
#define realloc
Definition: debug_ros.c:6
const char * strerror(int errnum)
Definition: compat_str.c:23
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void * safe_realloc(void *ptr, size_t size)
Definition: compat_str.c:16
int sys_nerr
char * compat_strdup(const char *src)
Definition: compat_str.c:32
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
char * sys_errlist[]
#define malloc
Definition: debug_ros.c:4
static char * dest
Definition: rtl.c:135