From 2eb1573f01710832bbe60a4ece89cb301727612a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 8 Dec 2010 06:26:04 -0500 Subject: hashtable: drop all non-reentrant versions The non-reentrant versions of the hashtable functions operate on a single shared hashtable. So if two different people try using these funcs for two different purposes, they'll cause problems for the other. Avoid this by converting all existing hashtable consumers over to the reentrant versions and then punting the non-reentrant ones. Signed-off-by: Mike Frysinger --- common/cmd_nvedit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'common/cmd_nvedit.c') diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index c3b57f2ff3a..f8c79763bf9 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -111,7 +111,7 @@ static int env_print(char *name) e.key = name; e.data = NULL; - ep = hsearch (e, FIND); + hsearch_r(e, FIND, &ep, &env_htab); if (ep == NULL) return 0; len = printf ("%s=%s\n", ep->key, ep->data); @@ -119,7 +119,7 @@ static int env_print(char *name) } /* print whole list */ - len = hexport('\n', &res, 0); + len = hexport_r(&env_htab, '\n', &res, 0); if (len > 0) { puts(res); @@ -184,7 +184,7 @@ int _do_env_set (int flag, int argc, char * const argv[]) */ e.key = name; e.data = NULL; - ep = hsearch (e, FIND); + hsearch_r(e, FIND, &ep, &env_htab); /* Check for console redirection */ if (strcmp(name,"stdin") == 0) { @@ -267,7 +267,7 @@ int _do_env_set (int flag, int argc, char * const argv[]) /* Delete only ? */ if ((argc < 3) || argv[2] == NULL) { - int rc = hdelete(name); + int rc = hdelete_r(name, &env_htab); return !rc; } @@ -293,7 +293,7 @@ int _do_env_set (int flag, int argc, char * const argv[]) e.key = name; e.data = value; - ep = hsearch(e, ENTER); + hsearch_r(e, ENTER, &ep, &env_htab); free(value); if (!ep) { printf("## Error inserting \"%s\" variable, errno=%d\n", @@ -456,7 +456,7 @@ char *getenv (char *name) e.key = name; e.data = NULL; - ep = hsearch (e, FIND); + hsearch_r(e, FIND, &ep, &env_htab); return (ep ? ep->data : NULL); } @@ -651,7 +651,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv } if (sep) { /* export as text file */ - len = hexport(sep, &addr, size); + len = hexport_r(&env_htab, sep, &addr, size); if (len < 0) { error("Cannot export environment: errno = %d\n", errno); @@ -670,7 +670,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv else /* export as raw binary data */ res = addr; - len = hexport('\0', &res, ENV_SIZE); + len = hexport_r(&env_htab, '\0', &res, ENV_SIZE); if (len < 0) { error("Cannot export environment: errno = %d\n", errno); @@ -790,7 +790,7 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg addr = (char *)ep->data; } - if (himport(addr, size, sep, del ? 0 : H_NOCLEAR) == 0) { + if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR) == 0) { error("Environment import failed: errno = %d\n", errno); return 1; } -- cgit v1.2.3