diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-08-11 13:03:25 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-09-04 10:32:02 +0200 |
commit | 4569a895f9b978a94c805ee2f2ae66bfb9a2ee70 (patch) | |
tree | 79e7f1a3aa7ee5fda5e9fe4ec8982ef8503c6099 /include | |
parent | b6776b3ca5498f8b9184f142056d2d0ce5e10fdc (diff) | |
download | mariadb-git-4569a895f9b978a94c805ee2f2ae66bfb9a2ee70.tar.gz |
simplify and unify my_safe_alloca usage
Diffstat (limited to 'include')
-rw-r--r-- | include/my_sys.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 2466d4ec430..453d1322cb5 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -205,16 +205,17 @@ extern void my_large_free(uchar *ptr); #endif /* GNUC */ #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) ((void)0) -#define my_safe_alloca(size, max_alloca_sz) ((size <= max_alloca_sz) ? \ - my_alloca(size) : \ - my_malloc(size, MYF(0))) -#define my_safe_afree(ptr, size, max_alloca_sz) if (size > max_alloca_sz) \ - my_free(ptr) +#define MAX_ALLOCA_SZ 4096 +#define my_safe_alloca(size) (((size) <= MAX_ALLOCA_SZ) ? \ + my_alloca(size) : \ + my_malloc((size), MYF(MY_THREAD_SPECIFIC|MY_WME))) +#define my_safe_afree(ptr, size) \ + do { if ((size) > MAX_ALLOCA_SZ) my_free(ptr); } while(0) #else #define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE)) #define my_afree(PTR) my_free(PTR) -#define my_safe_alloca(size, max_alloca_sz) my_alloca(size) -#define my_safe_afree(ptr, size, max_alloca_sz) my_afree(ptr) +#define my_safe_alloca(size) my_alloca(size) +#define my_safe_afree(ptr, size) my_afree(ptr) #endif /* HAVE_ALLOCA */ #ifndef errno /* did we already get it? */ |