aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-14 01:02:05 +0200
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-20 19:14:50 +0200
commit9eb5b4659d24fcceaa4761c3dfa2c7b1d5e60e81 (patch)
tree2c18fd36e1112381af0e82c4edd049df57a8f300 /shell
parent60d284141d301647e4fdfd0d6d0f792ba984df33 (diff)
downloadbusybox-w32-9eb5b4659d24fcceaa4761c3dfa2c7b1d5e60e81.tar.gz
busybox-w32-9eb5b4659d24fcceaa4761c3dfa2c7b1d5e60e81.tar.bz2
busybox-w32-9eb5b4659d24fcceaa4761c3dfa2c7b1d5e60e81.zip
win32: ash: sticky_free()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 767c095e7..d21922f66 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -112,6 +112,8 @@ struct forkshell {
112 struct strlist *strlist; 112 struct strlist *strlist;
113 pid_t pid; 113 pid_t pid;
114}; 114};
115static void sticky_free(void *p);
116#define free(p) sticky_free(p)
115static int spawn_forkshell(struct job *jp, struct forkshell *fs, int mode); 117static int spawn_forkshell(struct job *jp, struct forkshell *fs, int mode);
116#endif 118#endif
117 119
@@ -13783,6 +13785,7 @@ forkshell_prepare(struct forkshell *fs)
13783#undef exception_handler 13785#undef exception_handler
13784#undef trap 13786#undef trap
13785#undef trap_ptr 13787#undef trap_ptr
13788static void *sticky_mem_start, *sticky_mem_end;
13786static void 13789static void
13787forkshell_init(const char *idstr) 13790forkshell_init(const char *idstr)
13788{ 13791{
@@ -13801,6 +13804,9 @@ forkshell_init(const char *idstr)
13801 if (!fs) 13804 if (!fs)
13802 bb_error_msg_and_die("Invalid forkshell memory"); 13805 bb_error_msg_and_die("Invalid forkshell memory");
13803 13806
13807 /* this memory can't be freed */
13808 sticky_mem_start = fs;
13809 sticky_mem_end = (char *) fs + fs->size;
13804 /* pointer fixup */ 13810 /* pointer fixup */
13805 nodeptr = (int*)((char*)fs + fs->nodeptr_offset); 13811 nodeptr = (int*)((char*)fs + fs->nodeptr_offset);
13806 while (*nodeptr) { 13812 while (*nodeptr) {
@@ -13837,6 +13843,15 @@ forkshell_init(const char *idstr)
13837 fs->fp(fs); 13843 fs->fp(fs);
13838} 13844}
13839 13845
13846#undef free
13847static void
13848sticky_free(void *base)
13849{
13850 if (base >= sticky_mem_start && base < sticky_mem_end)
13851 return;
13852 free(base);
13853}
13854
13840/*- 13855/*-
13841 * Copyright (c) 1989, 1991, 1993, 1994 13856 * Copyright (c) 1989, 1991, 1993, 1994
13842 * The Regents of the University of California. All rights reserved. 13857 * The Regents of the University of California. All rights reserved.