diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-01-14 17:22:35 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-01-14 17:22:35 +0000 |
commit | 53e93916efb80159ce29c4a96a267e58acbaeab1 (patch) | |
tree | 7c669e3c4db4fb9a777331e357c86277fa63cb60 /mpfr-gmp.h | |
parent | 3cb9f37101152fe224cd388d0949ea8761ce0cf1 (diff) | |
download | mpfr-53e93916efb80159ce29c4a96a267e58acbaeab1.tar.gz |
mpfr-gmp.{c,h}: no longer use alloca() for the temporary allocations as
this can make MPFR crash in some high precisions, due to limited stack.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5186 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'mpfr-gmp.h')
-rw-r--r-- | mpfr-gmp.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/mpfr-gmp.h b/mpfr-gmp.h index d2d87fd14..21d6f6151 100644 --- a/mpfr-gmp.h +++ b/mpfr-gmp.h @@ -172,12 +172,6 @@ __MPFR_DECLSPEC void mpfr_assert_fail _MPFR_PROTO((const char *, int, #undef XDEBUG #define XDEBUG -/* Temp memory allocate */ -#define TMP_DECL(m) -#define TMP_ALLOC(x) alloca(x) -#define TMP_MARK(m) -#define TMP_FREE(m) - /* For longlong.h */ #ifdef HAVE_ATTRIBUTE_MODE typedef unsigned int UQItype __attribute__ ((mode (QI))); @@ -297,6 +291,24 @@ __MPFR_DECLSPEC void *__gmp_default_reallocate _MPFR_PROTO ((void *, size_t, size_t)); __MPFR_DECLSPEC void __gmp_default_free _MPFR_PROTO ((void *, size_t)); +/* Temp memory allocate */ + +struct tmp_marker +{ + void *ptr; + size_t size; + struct tmp_marker *next; +}; + +__MPFR_DECLSPEC void *mpfr_tmp_allocate _MPFR_PROTO ((struct tmp_marker **, + size_t)); +__MPFR_DECLSPEC void mpfr_tmp_free _MPFR_PROTO ((struct tmp_marker *)); + +#define TMP_DECL(m) struct tmp_marker *tmp_marker +#define TMP_ALLOC(x) mpfr_tmp_allocate (&tmp_marker, (x)) +#define TMP_MARK(m) tmp_marker = 0; +#define TMP_FREE(m) mpfr_tmp_free (tmp_marker) + #if defined (__cplusplus) } #endif |