From 66890465be761445e3f9929e9d24f3f4dbb580bc Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Tue, 18 Feb 1997 07:31:49 +0000 Subject: [PATCH] Because you cannot call malloc() during DLL initialization under win16, we must pre-allocate an array sufficiently large to hold several error tables. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9895 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/et/error_message.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index 024140936..e24bb2ced 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -168,6 +168,10 @@ add_error_table(et) const struct error_table FAR * et; { struct et_list *el = _et_list; +#ifdef _MSDOS + static struct et_list etl[32]; + static int etl_used = 0; +#endif while (el) { if (el->table->base == et->base) @@ -175,8 +179,18 @@ add_error_table(et) el = el->next; } - if (! (el = (struct et_list *)malloc(sizeof(struct et_list)))) - return ENOMEM; +#ifdef _MSDOS + /* + * Win16 applications cannot call malloc while the DLL is being + * initialized... To get around this, we pre-allocate an array + * sufficient to hold several error tables. + */ + if (etl_used < sizeof(etl)/sizeof(struct et_list)) + el = &etl[etl_used++]; + else +#endif + if (!(el = (struct et_list *)malloc(sizeof(struct et_list)))) + return ENOMEM; el->table = et; el->next = _et_list; -- 2.26.2