From 6482937de0dea6d674c05196ece8c3435c645333 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Tue, 16 Mar 2010 12:08:40 +0000 Subject: bibtex8/bibtexu dynamic memory allocation git-svn-id: svn://tug.org/texlive/trunk@17464 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/bibtex8/bibtex.h | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'Build/source/texk/bibtex8/bibtex.h') diff --git a/Build/source/texk/bibtex8/bibtex.h b/Build/source/texk/bibtex8/bibtex.h index 8ce8b5e752e..57225a9e1e8 100644 --- a/Build/source/texk/bibtex8/bibtex.h +++ b/Build/source/texk/bibtex8/bibtex.h @@ -269,14 +269,14 @@ #define BUF_SIZE 10000 #define MAX_CITES 2000 -#define MAX_ENT_INTS 10000 -#define MAX_ENT_STRS 10000 -#define MAX_FIELDS 17250L +#define MAX_ENT_INTS 3000 +#define MAX_ENT_STRS 3000 +#define MAX_FIELDS 5000 #define MAX_STRINGS 12000 #define POOL_SIZE 65000L #define MIN_CROSSREFS 2 -#define WIZ_FN_SPACE 5000 +#define WIZ_FN_SPACE 3000 #define SINGLE_FN_SPACE 100 #define ENT_STR_SIZE 250 #define GLOB_STR_SIZE 1000 @@ -980,7 +980,7 @@ * sure it will fit; for use in |int_to_ASCII|. ***************************************************************************/ #define APPEND_INT_CHAR(X) {\ - if (int_ptr == BUF_SIZE)\ + if (int_ptr == Buf_Size)\ { buffer_overflow ();}\ int_buf[int_ptr] = (X);\ INCR (int_ptr); } @@ -1125,7 +1125,7 @@ * will fit; since it's so low level, it's implemented as a macro. ***************************************************************************/ #define COPY_CHAR(X) {\ - if (FIELD_END == BUF_SIZE)\ + if (FIELD_END == Buf_Size)\ { BIB_FIELD_TOO_LONG_ERR; }\ else\ { FIELD_VL_STR[FIELD_END] = (X);\ @@ -1305,7 +1305,7 @@ ex_buf[ex_buf_ptr] = (X);\ INCR(ex_buf_ptr);} #define APPEND_EX_BUF_CHAR_AND_CHECK(X) {\ - if (ex_buf_ptr == BUF_SIZE) {buffer_overflow ();}; \ + if (ex_buf_ptr == Buf_Size) {buffer_overflow ();}; \ APPEND_EX_BUF_CHAR(X)} /*************************************************************************** @@ -1470,5 +1470,29 @@ #define ENTRY_STRS(_r,_c) entry_strs[(_r * (ENT_STR_SIZE+1)) + _c] #define GLOBAL_STRS(_r,_c) global_strs[(_r * (GLOB_STR_SIZE+1)) + _c] + +/*************************************************************************** + * WEB section number: N/A + * ~~~~~~~~~~~~~~~~~~~ + * Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically + * resize arrays. + ***************************************************************************/ +/* Reallocate N items of type T for ARRAY using myrealloc. */ +#define MYRETALLOC(array, addr, n, t) ((addr) = (t *) myrealloc(addr, (n) * sizeof(t), array)) +/* BibTeX needs this to dynamically reallocate arrays. Too bad we can't + rely on stringification, or we could avoid the ARRAY_NAME arg. + Actually allocate one more than requests, so we can index the last + entry, as Pascal wants to do. */ +#define BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size) \ + if (log_file != NULL)\ + fprintf (log_file, "Reallocated %s (elt_size=%d) to %ld items from %ld.\n", \ + array_name, (int) sizeof (type), new_size, size_var); \ + MYRETALLOC (array_name, array_var, new_size + 1, type) +/* Same as above, but also increase SIZE_VAR for the last (or only) array. */ +#define BIB_XRETALLOC(array_name, array_var, type, size_var, new_size) do { \ + BIB_XRETALLOC_NOSET(array_name, array_var, type, size_var, new_size); \ + size_var = new_size; \ +} while (0) + #endif /* __BIBTEX_H__ */ -- cgit v1.2.3