1 /***************************************************************************
2 strnew.cpp - description
3 -------------------
4 begin : 28-04-2008
5 copyright : (C) 2008 by fahr
6 email : fahr at inbox dot ru
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include <string.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21
22 #ifndef __MINGW32__
23 extern "C" void *ADM_alloc(int sz);
24 #else
25 #define ADM_alloc malloc
26 #endif
27
strnew(const char * instr)28 extern "C" char *strnew (const char *instr)
29 {
30 if (!instr)
31 return NULL;
32 size_t sl = strlen (instr);
33 char *tmp = (char*) ADM_alloc (sl + 1);
34 memcpy (tmp, instr, sl + 1);
35 return tmp;
36 }
37