From 3250a1932b5984b8801b62f81ab8413dd347bc5f Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 17 Jan 2000 09:34:45 +0000 Subject: zsh-workers/9329 --- Src/Modules/parameter.c | 2 +- Src/Zle/complete.c | 21 ++++++++++++++------- Src/Zle/zleparameter.c | 2 +- Src/glob.c | 3 +++ Src/mem.c | 6 +++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 94aff0c18..b0ea78ac7 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -58,7 +58,7 @@ createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan) pm->gets.hfn = hashgetfn; pm->sets.hfn = hashsetfn; pm->unsetfn = stdunsetfn; - pm->u.hash = ht = newhashtable(7, name, NULL); + pm->u.hash = ht = newhashtable(0, name, NULL); ht->hash = hasher; ht->emptytable = (TableFunc) shempty; diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index fa1476a90..d4c9f76c8 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -1133,14 +1133,21 @@ static void compunsetfn(Param pm, int exp) { if (exp) { - if (PM_TYPE(pm->flags) == PM_SCALAR) { - zsfree(*((char **) pm->u.data)); - *((char **) pm->u.data) = ztrdup(""); - } else if (PM_TYPE(pm->flags) == PM_ARRAY) { - freearray(*((char ***) pm->u.data)); - *((char ***) pm->u.data) = zcalloc(sizeof(char *)); + if (pm->u.data) { + if (PM_TYPE(pm->flags) == PM_SCALAR) { + zsfree(*((char **) pm->u.data)); + *((char **) pm->u.data) = ztrdup(""); + } else if (PM_TYPE(pm->flags) == PM_ARRAY) { + freearray(*((char ***) pm->u.data)); + *((char ***) pm->u.data) = zcalloc(sizeof(char *)); + } else if (PM_TYPE(pm->flags) == PM_HASHED) { + deleteparamtable(pm->u.hash); + pm->u.hash = NULL; + } } - pm->flags |= PM_UNSET; + } else if (PM_TYPE(pm->flags) == PM_HASHED) { + deletehashtable(pm->u.hash); + pm->u.hash = NULL; } } diff --git a/Src/Zle/zleparameter.c b/Src/Zle/zleparameter.c index d10fe99b1..1ef3c1b40 100644 --- a/Src/Zle/zleparameter.c +++ b/Src/Zle/zleparameter.c @@ -54,7 +54,7 @@ createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan) pm->gets.hfn = hashgetfn; pm->sets.hfn = hashsetfn; pm->unsetfn = stdunsetfn; - pm->u.hash = ht = newhashtable(7, name, NULL); + pm->u.hash = ht = newhashtable(0, name, NULL); ht->hash = hasher; ht->emptytable = (TableFunc) shempty; diff --git a/Src/glob.c b/Src/glob.c index 77729b45c..571091cc4 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -179,12 +179,15 @@ static struct globdata curglobdata; memcpy(&(N), &curglobdata, sizeof(struct globdata)); \ (N).gd_pathpos = pathpos; \ (N).gd_pathbuf = pathbuf; \ + (N).gd_pathbufsz = 0; \ + (N).gd_pathbuf = NULL; \ (N).gd_glob_pre = glob_pre; \ (N).gd_glob_suf = glob_suf; \ } while (0) #define restore_globstate(N) \ do { \ + zfree(pathbuf, pathbufsz); \ memcpy(&curglobdata, &(N), sizeof(struct globdata)); \ pathpos = (N).gd_pathpos; \ pathbuf = (N).gd_pathbuf; \ diff --git a/Src/mem.c b/Src/mem.c index 372c1e467..dcd6352ca 100644 --- a/Src/mem.c +++ b/Src/mem.c @@ -689,8 +689,8 @@ struct m_hdr { * back; note that this has to be less than M_FREE * M_ALLOC is the number of extra bytes to request from the system */ -#define M_FREE 65536 -#define M_KEEP 32768 +#define M_FREE 32768 +#define M_KEEP 16384 #define M_ALLOC M_KEEP /* a pointer to the last free block, a pointer to the free list (the blocks @@ -737,7 +737,7 @@ static char *m_high, *m_low; #define M_BSLEN(S) (((S) - sizeof(struct m_shdr *) - \ sizeof(zlong) - sizeof(struct m_hdr *)) / M_SNUM) #endif -#define M_NSMALL 13 +#define M_NSMALL 8 static struct m_hdr *m_small[M_NSMALL]; -- cgit 1.4.1