1 /*****************************************************************************/ 2 /* LibreDWG - free implementation of the DWG file format */ 3 /* */ 4 /* Copyright (C) 2019 Free Software Foundation, Inc. */ 5 /* */ 6 /* This library is free software, licensed under the terms of the GNU */ 7 /* General Public License as published by the Free Software Foundation, */ 8 /* either version 3 of the License, or (at your option) any later version. */ 9 /* You should have received a copy of the GNU General Public License */ 10 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */ 11 /*****************************************************************************/ 12 13 /* 14 * myalloca.h: alloca checks and replacement, use with freea() 15 * written by Reini Urban 16 */ 17 18 #ifndef MYALLOCA_H 19 #define MYALLOCA_H 20 21 #include "config.h" 22 #if defined HAVE_ALLOCA_H 23 # include <alloca.h> 24 #elif defined __GNUC__ 25 # undef alloca 26 # define alloca __builtin_alloca 27 #elif defined _AIX 28 # undef alloca 29 # define alloca __alloca 30 #elif defined _MSC_VER 31 # undef alloca 32 # include <malloc.h> 33 # define alloca _alloca 34 #else 35 # include <stddef.h> 36 # ifdef __cplusplus 37 extern "C" 38 # endif 39 void *alloca (size_t); 40 #endif 41 42 #ifndef HAVE_ALLOCA 43 static inline char *alloca (size_t size); 44 static inline char * alloca(size_t size)45alloca (size_t size) 46 { 47 return malloc (size); 48 } 49 # define freea(ptr) free (ptr) 50 #else 51 # define freea(ptr) 52 #endif 53 54 #endif 55