From 910863e9ea5e1a4db192b5be1630d125cff18485 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 9 Feb 2012 19:26:44 -0800 Subject: [PATCH] Final removal of halloc. It's like Christmas Morning. --- FishsFish.xcodeproj/project.pbxproj | 10 -- Makefile.in | 125 +++++++------ common.cpp | 2 - expand.cpp | 2 - fish.cpp | 5 - fish_indent.cpp | 6 - fish_pager.cpp | 7 +- fish_tests.cpp | 4 - fishd.cpp | 4 - function.cpp | 2 - halloc.cpp | 264 ---------------------------- halloc.h | 49 ------ halloc_util.cpp | 87 --------- halloc_util.h | 60 ------- output.cpp | 1 - parse_util.cpp | 1 - parser.cpp | 23 +-- path.cpp | 2 - path.h | 1 - proc.cpp | 17 +- wildcard.cpp | 1 - wutil.cpp | 21 +-- wutil.h | 2 +- 23 files changed, 78 insertions(+), 618 deletions(-) delete mode 100644 halloc.cpp delete mode 100644 halloc.h delete mode 100644 halloc_util.cpp delete mode 100644 halloc_util.h diff --git a/FishsFish.xcodeproj/project.pbxproj b/FishsFish.xcodeproj/project.pbxproj index 43f764d09..d6a14d51d 100644 --- a/FishsFish.xcodeproj/project.pbxproj +++ b/FishsFish.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXFileReference section */ - D03EE83714DF88B200FC7150 /* lru.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = lru.cpp; sourceTree = ""; }; D03EE83814DF88B200FC7150 /* lru.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lru.h; sourceTree = ""; }; D0A0850313B3ACEE0099B651 /* builtin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = builtin.h; sourceTree = ""; }; D0A0850413B3ACEE0099B651 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = ""; }; @@ -21,8 +20,6 @@ D0A0850C13B3ACEE0099B651 /* expand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expand.h; sourceTree = ""; }; D0A0850D13B3ACEE0099B651 /* fallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fallback.h; sourceTree = ""; }; D0A0850E13B3ACEE0099B651 /* function.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = function.h; sourceTree = ""; }; - D0A0850F13B3ACEE0099B651 /* halloc_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = halloc_util.h; sourceTree = ""; }; - D0A0851013B3ACEE0099B651 /* halloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = halloc.h; sourceTree = ""; }; D0A0851113B3ACEE0099B651 /* highlight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = highlight.h; sourceTree = ""; }; D0A0851213B3ACEE0099B651 /* history.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = history.h; sourceTree = ""; }; D0A0851313B3ACEE0099B651 /* input_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input_common.h; sourceTree = ""; }; @@ -75,8 +72,6 @@ D0A0854213B3ACEE0099B651 /* fish.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fish.cpp; sourceTree = ""; }; D0A0854313B3ACEE0099B651 /* fishd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fishd.cpp; sourceTree = ""; }; D0A0854413B3ACEE0099B651 /* function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = function.cpp; sourceTree = ""; }; - D0A0854513B3ACEE0099B651 /* halloc_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = halloc_util.cpp; sourceTree = ""; }; - D0A0854613B3ACEE0099B651 /* halloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = halloc.cpp; sourceTree = ""; }; D0A0854713B3ACEE0099B651 /* highlight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = highlight.cpp; sourceTree = ""; }; D0A0854813B3ACEE0099B651 /* history.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = history.cpp; sourceTree = ""; }; D0A0854913B3ACEE0099B651 /* input_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = input_common.cpp; sourceTree = ""; }; @@ -153,10 +148,6 @@ D0A0854113B3ACEE0099B651 /* fish_tests.cpp */, D0A0854213B3ACEE0099B651 /* fish.cpp */, D0A0854313B3ACEE0099B651 /* fishd.cpp */, - D0A0850F13B3ACEE0099B651 /* halloc_util.h */, - D0A0851013B3ACEE0099B651 /* halloc.h */, - D0A0854613B3ACEE0099B651 /* halloc.cpp */, - D0A0854513B3ACEE0099B651 /* halloc_util.cpp */, D0A0851113B3ACEE0099B651 /* highlight.h */, D0A0854713B3ACEE0099B651 /* highlight.cpp */, D0A0851213B3ACEE0099B651 /* history.h */, @@ -175,7 +166,6 @@ D0A0854F13B3ACEE0099B651 /* kill.cpp */, D0A0854E13B3ACEE0099B651 /* key_reader.cpp */, D03EE83814DF88B200FC7150 /* lru.h */, - D03EE83714DF88B200FC7150 /* lru.cpp */, D0A0851913B3ACEE0099B651 /* mimedb.h */, D0A0855013B3ACEE0099B651 /* mimedb.cpp */, D0A0851A13B3ACEE0099B651 /* output.h */, diff --git a/Makefile.in b/Makefile.in index cccf79640..73c5d8d5f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,7 +84,7 @@ HAVE_GETTEXT=@HAVE_GETTEXT@ #.h file. # -COMMON_FILES := util.cpp halloc.cpp halloc_util.cpp fallback.cpp +COMMON_FILES := util.cpp fallback.cpp # @@ -917,118 +917,114 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -autoload.o: config.h autoload.h common.h util.h wutil.h signal.h env.h exec.h -autoload.o: proc.h io.h +autoload.o: config.h autoload.h common.h util.h lru.h wutil.h signal.h env.h +autoload.o: builtin_scripts.h exec.h proc.h io.h builtin.o: config.h signal.h fallback.h util.h wutil.h builtin.h io.h -builtin.o: common.h function.h complete.h proc.h parser.h event.h reader.h +builtin.o: common.h function.h event.h complete.h proc.h parser.h reader.h builtin.o: env.h wgetopt.h sanity.h tokenizer.h wildcard.h input_common.h -builtin.o: input.h intern.h exec.h highlight.h halloc.h halloc_util.h -builtin.o: parse_util.h autoload.h parser_keywords.h expand.h path.h -builtin.o: builtin_set.cpp builtin_commandline.cpp builtin_complete.cpp -builtin.o: builtin_ulimit.cpp builtin_jobs.cpp +builtin.o: input.h intern.h exec.h highlight.h parse_util.h autoload.h lru.h +builtin.o: parser_keywords.h expand.h path.h builtin_set.cpp +builtin.o: builtin_commandline.cpp builtin_complete.cpp builtin_ulimit.cpp +builtin.o: builtin_jobs.cpp builtin_commandline.o: config.h signal.h fallback.h util.h wutil.h builtin.h builtin_commandline.o: io.h common.h wgetopt.h reader.h proc.h parser.h -builtin_commandline.o: event.h tokenizer.h input_common.h input.h -builtin_commandline.o: parse_util.h autoload.h +builtin_commandline.o: event.h function.h tokenizer.h input_common.h input.h +builtin_commandline.o: parse_util.h autoload.h lru.h builtin_complete.o: config.h signal.h fallback.h util.h wutil.h builtin.h builtin_complete.o: io.h common.h complete.h wgetopt.h parser.h proc.h -builtin_complete.o: event.h reader.h +builtin_complete.o: event.h function.h reader.h builtin_jobs.o: config.h fallback.h signal.h util.h wutil.h builtin.h io.h -builtin_jobs.o: common.h proc.h parser.h event.h wgetopt.h +builtin_jobs.o: common.h proc.h parser.h event.h function.h wgetopt.h +builtin_scripts.o: builtin_scripts.h builtin_set.o: config.h signal.h fallback.h util.h wutil.h builtin.h io.h builtin_set.o: common.h env.h expand.h wgetopt.h proc.h parser.h event.h +builtin_set.o: function.h builtin_ulimit.o: config.h fallback.h signal.h util.h builtin.h io.h common.h builtin_ulimit.o: wgetopt.h common.o: config.h fallback.h signal.h util.h wutil.h common.h expand.h -common.o: proc.h io.h wildcard.h parser.h event.h complete.h util.cpp -common.o: halloc.cpp halloc.h halloc_util.cpp fallback.cpp +common.o: proc.h io.h wildcard.h parser.h event.h function.h complete.h +common.o: util.cpp fallback.cpp complete.o: config.h signal.h fallback.h util.h tokenizer.h wildcard.h complete.o: common.h proc.h io.h parser.h event.h function.h complete.h complete.o: builtin.h env.h exec.h expand.h reader.h history.h intern.h -complete.o: parse_util.h autoload.h parser_keywords.h halloc.h halloc_util.h -complete.o: wutil.h path.h +complete.o: parse_util.h autoload.h lru.h parser_keywords.h wutil.h path.h +complete.o: builtin_scripts.h env.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h env.h -env.o: sanity.h expand.h history.h reader.h parser.h event.h env_universal.h -env.o: env_universal_common.h input_common.h path.h halloc.h halloc_util.h +env.o: sanity.h expand.h history.h reader.h parser.h event.h function.h +env.o: env_universal.h env_universal_common.h input_common.h path.h env.o: complete.h env_universal.o: config.h signal.h fallback.h util.h common.h wutil.h env_universal.o: env_universal_common.h env_universal.h env_universal_common.o: config.h signal.h fallback.h util.h common.h wutil.h env_universal_common.o: env_universal_common.h event.o: config.h signal.h fallback.h util.h wutil.h function.h common.h -event.o: proc.h io.h parser.h event.h halloc_util.h +event.o: event.h proc.h io.h parser.h exec.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h -exec.o: exec.h parser.h event.h builtin.h function.h env.h wildcard.h -exec.o: sanity.h expand.h halloc.h halloc_util.h parse_util.h autoload.h +exec.o: exec.h parser.h event.h function.h builtin.h env.h wildcard.h +exec.o: sanity.h expand.h parse_util.h autoload.h lru.h expand.o: config.h signal.h fallback.h util.h common.h wutil.h env.h proc.h -expand.o: io.h parser.h event.h expand.h wildcard.h exec.h tokenizer.h -expand.o: complete.h parse_util.h autoload.h halloc.h halloc_util.h +expand.o: io.h parser.h event.h function.h expand.h wildcard.h exec.h +expand.o: tokenizer.h complete.h parse_util.h autoload.h lru.h fallback.o: config.h fallback.h signal.h util.h fish.o: config.h signal.h fallback.h util.h common.h reader.h io.h builtin.h -fish.o: function.h complete.h wutil.h env.h sanity.h proc.h parser.h event.h -fish.o: expand.h intern.h exec.h output.h halloc.h halloc_util.h history.h -fish.o: path.h -fish_indent.o: config.h fallback.h signal.h util.h common.h wutil.h halloc.h -fish_indent.o: halloc_util.h tokenizer.h print_help.h parser_keywords.h +fish.o: function.h event.h complete.h wutil.h env.h sanity.h proc.h parser.h +fish.o: expand.h intern.h exec.h output.h history.h path.h +fish_indent.o: config.h fallback.h signal.h util.h common.h wutil.h +fish_indent.o: tokenizer.h print_help.h parser_keywords.h fish_pager.o: config.h signal.h fallback.h util.h wutil.h common.h complete.h fish_pager.o: output.h input_common.h env_universal.h env_universal_common.h -fish_pager.o: halloc.h halloc_util.h print_help.h +fish_pager.o: print_help.h fish_tests.o: config.h signal.h fallback.h util.h common.h proc.h io.h -fish_tests.o: reader.h builtin.h function.h autoload.h complete.h wutil.h -fish_tests.o: env.h expand.h parser.h event.h tokenizer.h output.h exec.h -fish_tests.o: path.h halloc.h halloc_util.h +fish_tests.o: reader.h builtin.h function.h event.h autoload.h lru.h +fish_tests.o: complete.h wutil.h env.h expand.h parser.h tokenizer.h output.h +fish_tests.o: exec.h path.h history.h fishd.o: config.h signal.h fallback.h util.h common.h wutil.h -fishd.o: env_universal_common.h halloc.h halloc_util.h path.h print_help.h +fishd.o: env_universal_common.h path.h print_help.h function.o: config.h signal.h wutil.h fallback.h util.h function.h common.h -function.o: proc.h io.h parser.h event.h intern.h reader.h parse_util.h -function.o: autoload.h parser_keywords.h env.h expand.h halloc.h -function.o: halloc_util.h -halloc.o: config.h fallback.h signal.h util.h common.h halloc.h -halloc_util.o: config.h fallback.h signal.h util.h common.h halloc.h +function.o: event.h proc.h io.h parser.h intern.h reader.h parse_util.h +function.o: autoload.h lru.h parser_keywords.h env.h expand.h +function.o: builtin_scripts.h highlight.o: config.h signal.h fallback.h util.h wutil.h highlight.h env.h -highlight.o: common.h tokenizer.h proc.h io.h parser.h event.h parse_util.h -highlight.o: autoload.h parser_keywords.h builtin.h function.h expand.h -highlight.o: sanity.h complete.h output.h halloc.h halloc_util.h wildcard.h -highlight.o: path.h -history.o: config.h fallback.h signal.h util.h wutil.h history.h common.h -history.o: halloc.h halloc_util.h intern.h path.h +highlight.o: common.h tokenizer.h proc.h io.h parser.h event.h function.h +highlight.o: parse_util.h autoload.h lru.h parser_keywords.h builtin.h +highlight.o: expand.h sanity.h complete.h output.h wildcard.h path.h +history.o: config.h fallback.h signal.h util.h sanity.h wutil.h history.h +history.o: common.h intern.h path.h autoload.h lru.h input.o: config.h signal.h fallback.h util.h wutil.h reader.h io.h proc.h -input.o: common.h sanity.h input_common.h input.h parser.h event.h env.h -input.o: expand.h output.h intern.h halloc.h halloc_util.h +input.o: common.h sanity.h input_common.h input.h parser.h event.h function.h +input.o: env.h expand.h output.h intern.h input_common.o: config.h fallback.h signal.h util.h common.h wutil.h input_common.o: input_common.h env_universal.h env_universal_common.h input_common.o: iothread.h intern.o: config.h fallback.h signal.h util.h wutil.h common.h intern.h io.o: config.h fallback.h signal.h util.h wutil.h exec.h proc.h io.h common.h -io.o: halloc.h iothread.o: iothread.h signal.h key_reader.o: config.h fallback.h signal.h input_common.h kill.o: config.h signal.h fallback.h util.h wutil.h kill.h proc.h io.h -kill.o: common.h sanity.h env.h exec.h halloc.h path.h +kill.o: common.h sanity.h env.h exec.h path.h mimedb.o: config.h xdgmime.h fallback.h signal.h util.h print_help.h output.o: config.h signal.h fallback.h util.h wutil.h expand.h common.h -output.o: output.h halloc_util.h highlight.h env.h +output.o: output.h highlight.h env.h parse_util.o: config.h fallback.h signal.h util.h wutil.h common.h -parse_util.o: tokenizer.h parse_util.h autoload.h expand.h intern.h exec.h -parse_util.o: proc.h io.h env.h wildcard.h halloc_util.h +parse_util.o: tokenizer.h parse_util.h autoload.h lru.h expand.h intern.h +parse_util.o: exec.h proc.h io.h env.h wildcard.h parser.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h -parser.o: parser.h event.h parser_keywords.h tokenizer.h exec.h wildcard.h -parser.o: function.h builtin.h env.h expand.h reader.h sanity.h +parser.o: parser.h event.h function.h parser_keywords.h tokenizer.h exec.h +parser.o: wildcard.h builtin.h env.h expand.h reader.h sanity.h parser.o: env_universal.h env_universal_common.h intern.h parse_util.h -parser.o: autoload.h halloc.h halloc_util.h path.h complete.h +parser.o: autoload.h lru.h path.h complete.h parser_keywords.o: config.h fallback.h signal.h common.h util.h parser_keywords.o: parser_keywords.h -path.o: config.h fallback.h signal.h util.h common.h env.h wutil.h halloc.h -path.o: halloc_util.h path.h expand.h +path.o: config.h fallback.h signal.h util.h common.h env.h wutil.h path.h +path.o: expand.h print_help.o: print_help.h proc.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h -proc.o: reader.h sanity.h env.h parser.h event.h halloc.h halloc_util.h -proc.o: output.h +proc.o: reader.h sanity.h env.h parser.h event.h function.h output.h reader.o: config.h signal.h fallback.h util.h wutil.h highlight.h env.h -reader.o: common.h reader.h io.h proc.h parser.h event.h complete.h history.h -reader.o: sanity.h exec.h expand.h tokenizer.h kill.h input_common.h input.h -reader.o: function.h output.h screen.h halloc.h halloc_util.h iothread.h -reader.o: parse_util.h autoload.h +reader.o: common.h reader.h io.h proc.h parser.h event.h function.h +reader.o: complete.h history.h sanity.h exec.h expand.h tokenizer.h kill.h +reader.o: input_common.h input.h output.h screen.h iothread.h intern.h +reader.o: parse_util.h autoload.h lru.h sanity.o: config.h signal.h fallback.h util.h common.h sanity.h proc.h io.h sanity.o: history.h reader.h kill.h wutil.h screen.o: config.h fallback.h signal.h common.h util.h wutil.h output.h @@ -1040,9 +1036,8 @@ tokenizer.o: config.h fallback.h signal.h util.h wutil.h tokenizer.h common.h util.o: config.h fallback.h signal.h util.h common.h wutil.h wgetopt.o: config.h wgetopt.h wutil.h fallback.h signal.h wildcard.o: config.h fallback.h signal.h util.h wutil.h complete.h common.h -wildcard.o: wildcard.h reader.h io.h expand.h exec.h proc.h halloc_util.h -wutil.o: config.h fallback.h signal.h util.h common.h wutil.h halloc.h -wutil.o: halloc_util.h +wildcard.o: wildcard.h reader.h io.h expand.h exec.h proc.h +wutil.o: config.h fallback.h signal.h util.h common.h wutil.h xdgmime.o: xdgmime.h xdgmimeint.h xdgmimeglob.h xdgmimemagic.h xdgmimealias.h xdgmime.o: xdgmimeparent.h xdgmimealias.o: xdgmimealias.h xdgmime.h xdgmimeint.h diff --git a/common.cpp b/common.cpp index 40c07404f..777b39087 100644 --- a/common.cpp +++ b/common.cpp @@ -86,8 +86,6 @@ parts of fish. #include "complete.h" #include "util.cpp" -#include "halloc.cpp" -#include "halloc_util.cpp" #include "fallback.cpp" /** diff --git a/expand.cpp b/expand.cpp index de76da794..49a186d67 100644 --- a/expand.cpp +++ b/expand.cpp @@ -45,8 +45,6 @@ parameter expansion. #include "complete.h" #include "parse_util.h" -#include "halloc.h" -#include "halloc_util.h" /** Error issued on invalid variable name diff --git a/fish.cpp b/fish.cpp index 9b57bb1f4..3b8f92f8f 100644 --- a/fish.cpp +++ b/fish.cpp @@ -58,8 +58,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "exec.h" #include "event.h" #include "output.h" -#include "halloc.h" -#include "halloc_util.h" #include "history.h" #include "path.h" @@ -275,7 +273,6 @@ int main( int argc, char **argv ) const char *cmd=0; int my_optind=0; - halloc_util_init(); set_main_thread(); wsetlocale( LC_ALL, L"" ); @@ -389,8 +386,6 @@ int main( int argc, char **argv ) wutil_destroy(); event_destroy(); - halloc_util_destroy(); - env_destroy(); return res?STATUS_UNKNOWN_COMMAND:proc_get_last_status(); diff --git a/fish_indent.cpp b/fish_indent.cpp index 232c4f9f1..c1d24ef4c 100644 --- a/fish_indent.cpp +++ b/fish_indent.cpp @@ -37,8 +37,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "util.h" #include "common.h" #include "wutil.h" -#include "halloc.h" -#include "halloc_util.h" #include "tokenizer.h" #include "print_help.h" #include "parser_keywords.h" @@ -378,8 +376,6 @@ int main( int argc, char **argv ) } } - halloc_util_init(); - sb_init( &sb_in ); sb_init( &sb_out ); @@ -402,7 +398,5 @@ int main( int argc, char **argv ) wutil_destroy(); - halloc_util_destroy(); - return 0; } diff --git a/fish_pager.cpp b/fish_pager.cpp index 06273e751..822e2426f 100644 --- a/fish_pager.cpp +++ b/fish_pager.cpp @@ -59,8 +59,6 @@ #include "output.h" #include "input_common.h" #include "env_universal.h" -#include "halloc.h" -#include "halloc_util.h" #include "print_help.h" enum @@ -203,7 +201,7 @@ struct comp_t */ static int get_color( int highlight ) { - wchar_t *val; + const wchar_t *val; if( highlight < 0 ) return FISH_COLOR_NORMAL; @@ -1210,7 +1208,6 @@ int main( int argc, char **argv ) This initialization is made early, so that the other init code can use global_context for memory managment */ - halloc_util_init(); program_name = L"fish_pager"; @@ -1450,7 +1447,5 @@ int main( int argc, char **argv ) } destroy(); - halloc_util_destroy(); - } diff --git a/fish_tests.cpp b/fish_tests.cpp index 95ce0d318..06f5e6e40 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -49,8 +49,6 @@ #include "exec.h" #include "event.h" #include "path.h" -#include "halloc.h" -#include "halloc_util.h" #include "history.h" /** @@ -796,7 +794,6 @@ int main( int argc, char **argv ) say( L"Lines beginning with '(ignore):' are not errors, they are warning messages\ngenerated by the fish parser library when given broken input, and can be\nignored. All actual errors begin with 'Error:'." ); set_main_thread(); proc_init(); - halloc_util_init(); event_init(); function_init(); builtin_init(); @@ -827,6 +824,5 @@ int main( int argc, char **argv ) wutil_destroy(); event_destroy(); proc_destroy(); - halloc_util_destroy(); } diff --git a/fishd.cpp b/fishd.cpp index cd38cfdf9..c3ad0d151 100644 --- a/fishd.cpp +++ b/fishd.cpp @@ -70,8 +70,6 @@ time the original barrier request was sent have been received. #include "common.h" #include "wutil.h" #include "env_universal_common.h" -#include "halloc.h" -#include "halloc_util.h" #include "path.h" #include "print_help.h" @@ -572,7 +570,6 @@ int main( int argc, char ** argv ) fd_set read_fd, write_fd; - halloc_util_init(); set_main_thread(); program_name=L"fishd"; @@ -779,6 +776,5 @@ int main( int argc, char ** argv ) } } - halloc_util_destroy(); } diff --git a/function.cpp b/function.cpp index eda59d6d9..0a6553cad 100644 --- a/function.cpp +++ b/function.cpp @@ -36,8 +36,6 @@ #include "parser_keywords.h" #include "env.h" #include "expand.h" -#include "halloc.h" -#include "halloc_util.h" #include "builtin_scripts.h" /** diff --git a/halloc.cpp b/halloc.cpp deleted file mode 100644 index 2b4c78b42..000000000 --- a/halloc.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/** \file halloc.c - - A hierarchical memory allocation system. Works just like talloc - used in Samba, except that an arbitrary block allocated with - malloc() can be registered to be freed by halloc_free. - -*/ - -#include "config.h" - - -#include -#include - -#include "fallback.h" -#include "util.h" - -#include "common.h" -#include "halloc.h" - -/** - Extra size to allocate whenever doing a halloc, in order to fill uyp smaller halloc calls -*/ -#define HALLOC_BLOCK_SIZE 128 - -/** - Maximum size of trailing halloc space to refuse to discard. This is - set to be larger on 64-bit platforms, since we don't want to get - 'stuck' with an unusably small slice of memory, and what is - unusably small often depends on pointer size. -*/ -#define HALLOC_SCRAP_SIZE (4*sizeof(void *)) - -#ifdef HALLOC_DEBUG -/** - Debug statistic parameter -*/ -static int child_count=0; -/** - Debug statistic parameter -*/ -static int child_size=0; -/** - Debug statistic parameter -*/ -static int alloc_count =0; -/** - Debug statistic parameter -*/ -static int alloc_spill = 0; -/** - Debug statistic parameter -*/ -static pid_t pid=0; -/** - Debug statistic parameter -*/ -static int parent_count=0; -#endif - -/** - The main datastructure for a main halloc context -*/ -typedef struct halloc -{ - /** - List of all addresses and functions to call on them - */ - array_list_t children; - /** - Memory scratch area used to fullfil smaller memory allocations - */ - char *scratch; - /** - Amount of free space in the scratch area - */ - ssize_t scratch_free; -} - halloc_t; - -/** - Allign the specified pointer - */ -static char *align_ptr( char *in ) -{ - unsigned long step = maxi(sizeof(double),sizeof(void *)); - unsigned long inc = step-1; - unsigned long long_in = (long)in; - unsigned long long_out = ((long_in+inc)/step)*step; - return (char *)long_out; -} - -/** - Allign specifies size_t - */ -static size_t align_sz( size_t in ) -{ - size_t step = maxi(sizeof(double),sizeof(void *)); - size_t inc = step-1; - return ((in+inc)/step)*step; -} - -/** - Get the offset of the halloc structure before a data block -*/ -static halloc_t *halloc_from_data( void *data ) -{ - return (halloc_t *)(((char *)data) - align_sz(sizeof( halloc_t ) )); -} - -/** - A function that does nothing -*/ -static void late_free( void *data) -{ -} - -#ifdef HALLOC_DEBUG -/** - Debug function, called at exit when in debug mode. Prints usage - statistics, like number of allocations and number of internal calls - to malloc. -*/ -static void halloc_report() -{ - if( getpid() == pid ) - { - debug( 1, L"%d parents, %d children with average child size of %.2f bytes caused %d allocs, average spill of %.2f bytes", - parent_count, child_count, (double)child_size/child_count, - parent_count+alloc_count, (double)alloc_spill/(parent_count+alloc_count) ); - } -} -#endif - - -void *halloc( void *context, size_t size ) -{ - halloc_t *me, *parent; - if( context ) - { - char *res; - char *aligned; - -#ifdef HALLOC_DEBUG - - if( !child_count ) - { - pid = getpid(); - atexit( &halloc_report ); - } - - child_count++; - child_size += size; -#endif - parent = halloc_from_data( context ); - - /* - Align memory address - */ - aligned = align_ptr( parent->scratch ); - - parent->scratch_free -= (aligned-parent->scratch); - - if( parent->scratch_free < 0 ) - parent->scratch_free=0; - - parent->scratch = aligned; - - if( size <= parent->scratch_free ) - { - res = parent->scratch; - parent->scratch_free -= size; - parent->scratch = ((char *)parent->scratch)+size; - } - else - { - -#ifdef HALLOC_DEBUG - alloc_count++; -#endif - - if( parent->scratch_free < HALLOC_SCRAP_SIZE ) - { -#ifdef HALLOC_DEBUG - alloc_spill += parent->scratch_free; -#endif - res = (char *)calloc( 1, size + HALLOC_BLOCK_SIZE ); - if( !res ) - DIE_MEM(); - parent->scratch = (char *)res + size; - parent->scratch_free = HALLOC_BLOCK_SIZE; - } - else - { - res = (char *)calloc( 1, size ); - if( !res ) - DIE_MEM(); - } - al_push_func( &parent->children, (void (*)())&late_free ); - al_push( &parent->children, res ); - - } - return res; - - } - else - { - me = (halloc_t *)calloc( 1, align_sz(sizeof(halloc_t)) + align_sz(size) + HALLOC_BLOCK_SIZE ); - - if( !me ) - DIE_MEM(); -#ifdef HALLOC_DEBUG - parent_count++; -#endif - me->scratch = ((char *)me) + align_sz(sizeof(halloc_t)) + align_sz(size); - me->scratch_free = HALLOC_BLOCK_SIZE; - - al_init( &me->children ); - return ((char *)me) + align_sz(sizeof(halloc_t)); - } -} - -void halloc_register_function( void *context, void (*func)(void *), void *data ) -{ - halloc_t *me; - if( !context ) - return; - - me = halloc_from_data( context ); - al_push_func( &me->children, (void (*)())func ); - al_push( &me->children, data ); -} - -void halloc_free( void *context ) -{ - halloc_t *me; - int i; - - if( !context ) - return; - - - me = halloc_from_data( context ); - -#ifdef HALLOC_DEBUG - alloc_spill += me->scratch_free; -#endif - for( i=0; ichildren); i+=2 ) - { - void (*func)(void *) = (void (*)(void *))al_get( &me->children, i ); - void * data = (void *)al_get( &me->children, i+1 ); - if( func != &late_free ) - func( data ); - } - for( i=0; ichildren); i+=2 ) - { - void (*func)(void *) = (void (*)(void *))al_get_func( &me->children, i ); - void * data = (void *)al_get( &me->children, i+1 ); - if( func == &late_free ) - free( data ); - } - al_destroy( &me->children ); - free(me); -} diff --git a/halloc.h b/halloc.h deleted file mode 100644 index 1cdf89c07..000000000 --- a/halloc.h +++ /dev/null @@ -1,49 +0,0 @@ -/** \file halloc.h - - A hierarchical memory allocation system. Works mostly like talloc - used in Samba, except that an arbitrary block allocated with - malloc() can be registered to be freed by halloc_free. - -*/ - -#ifndef FISH_HALLOC_H -#define FISH_HALLOC_H - -/** - Allocate new memory using specified parent memory context. Context - _must_ be either 0 or the result of a previous call to halloc. The - resulting memory is set to zero. - - If \c context is null, the resulting block is a root block, and - must be freed with a call to halloc_free(). - - If \c context is not null, context must be a halloc root block. the - resulting memory block is a child context, and must never be - explicitly freed, it will be automatically freed whenever the - parent context is freed. Child blocks can also never be used as the - context in calls to halloc_register_function, halloc_free, etc. -*/ -void *halloc( void *context, size_t size ); - -/** - Make the specified function run whenever context is free'd, using data as argument. - - \c context a halloc root block -*/ -void halloc_register_function( void *context, void (*func)(void *), void *data ); - -/** - Free memory context and all children contexts. Only root contexts - may be freed explicitly. - - All functions registered with halloc_register_function are run in - the order they where added. Afterwards, all memory allocated using - halloc itself is free'd. - - \c context a halloc root block -*/ -void halloc_free( void *context ); - - -#endif - diff --git a/halloc_util.cpp b/halloc_util.cpp deleted file mode 100644 index 75a7f9235..000000000 --- a/halloc_util.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/** \file halloc_util.c - - A hierarchical memory allocation system. Works just like talloc - used in Samba, except that an arbitrary block allocated with - malloc() can be registered to be freed by halloc_free. - -*/ - -#include "config.h" - - -#include -#include -#include - -#include "fallback.h" -#include "util.h" - -#include "common.h" -#include "halloc.h" - -void *global_context=0; - -void halloc_util_init() -{ - global_context = halloc( 0, 0 ); -} - -void halloc_util_destroy() -{ - halloc_free( global_context ); -} - -array_list_t *al_halloc( void *context ) -{ - array_list_t *res = (array_list_t *)halloc( context, sizeof( array_list_t ) ); - if( !res ) - DIE_MEM(); - al_init( res ); - halloc_register_function( context?context:res, (void (*)(void *)) &al_destroy, res ); - return res; -} - -string_buffer_t *sb_halloc( void *context ) -{ - string_buffer_t *res = (string_buffer_t *)halloc( context, sizeof( string_buffer_t ) ); - if( !res ) - DIE_MEM(); - sb_init( res ); - halloc_register_function( context?context:res, (void (*)(void *)) &sb_destroy, res ); - return res; -} - -/** - A function that takes a single parameter, which is a function pointer, and calls it. -*/ -static void halloc_passthrough( void *f ) -{ - void (*func)() = (void (*)() )f; - func(); -} - -void halloc_register_function_void( void *context, void (*func)() ) -{ - halloc_register_function( context, &halloc_passthrough, (void *)func ); -} - -void *halloc_register( void *context, void *data ) -{ - if( !data ) - return 0; - - halloc_register_function( context, &free, data ); - return data; -} - -wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c ) -{ - wchar_t *res = (wchar_t *)halloc( context, sizeof(wchar_t)*(c+1) ); - if( res == 0 ) - { - DIE_MEM(); - } - wcslcpy( res, in, c+1 ); - res[c] = L'\0'; - return res; -} diff --git a/halloc_util.h b/halloc_util.h deleted file mode 100644 index 109277429..000000000 --- a/halloc_util.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - \file halloc_util.h - - Various halloc-related utility functions. -*/ - -#ifndef FISH_HALLOC_UTIL_H -#define FISH_HALLOC_UTIL_H - -/** - This pointer is a valid halloc context that will be freed right - before program shutdown. It may be used to allocate memory that - should be freed when the program shuts down. -*/ -extern void *global_context; - -/** - Create the global_context halloc object -*/ -void halloc_util_init(); - -/** - Free the global_context halloc object -*/ -void halloc_util_destroy(); - -/** - Allocate a array_list_t that will be automatically disposed of when - the specified context is free'd -*/ -array_list_t *al_halloc( void *context ); - -/** - Allocate a string_buffer_t that will be automatically disposed of - when the specified context is free'd -*/ -string_buffer_t *sb_halloc( void *context ); - -/** - Register the specified function to run when the specified context - is free'd. This function is related to halloc_register_function, - but the specified function dowes not take an argument. -*/ -void halloc_register_function_void( void *context, void (*func)() ); - -/** - Free the memory pointed to by \c data when the memory pointed to by - \c context is free:d. Note that this will _not_ turn the specified - memory area into a valid halloc context. Only memory areas created - using a call to halloc( 0, size ) can be used as a context. -*/ -void *halloc_register( void *context, void *data ); - -/** - Make a copy of the specified substring using memory allocated using - halloc and the specified context -*/ -wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c ); - -#endif diff --git a/output.cpp b/output.cpp index 6d085c9c8..64983e6ea 100644 --- a/output.cpp +++ b/output.cpp @@ -54,7 +54,6 @@ #include "expand.h" #include "common.h" #include "output.h" -#include "halloc_util.h" #include "highlight.h" /** diff --git a/parse_util.cpp b/parse_util.cpp index 795b4c536..7b3781d55 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -38,7 +38,6 @@ #include "env.h" #include "signal.h" #include "wildcard.h" -#include "halloc_util.h" /** Maximum number of autoloaded items opf a specific type to keep in diff --git a/parser.cpp b/parser.cpp index be5103318..409eb6246 100644 --- a/parser.cpp +++ b/parser.cpp @@ -40,8 +40,6 @@ The fish parser. Contains functions for parsing and evaluating code. #include "event.h" #include "intern.h" #include "parse_util.h" -#include "halloc.h" -#include "halloc_util.h" #include "path.h" #include "signal.h" #include "complete.h" @@ -394,11 +392,8 @@ static int block_count( block_t *b ) void parser_t::push_block( int type ) { -// block_t zerod = {}; -// block_t *newv = new block_t(zerod); - void *buffer = halloc( 0, sizeof( block_t )); - bzero(buffer, sizeof(block_t)); - block_t *newv = new(buffer) block_t(); + block_t zerod = {}; + block_t *newv = new block_t(zerod); newv->src_lineno = parser_t::get_lineno(); newv->src_filename = parser_t::current_filename()?intern(parser_t::current_filename()):0; @@ -460,8 +455,7 @@ void parser_t::pop_block() if (old->wants_pop_env) env_pop(); - old->~block_t(); - halloc_free(old); + delete old; } const wchar_t *parser_t::get_block_desc( int block ) const @@ -2795,12 +2789,6 @@ int parser_t::test( const wchar_t * buff, */ int needs_cmd=0; - /* - halloc context used for calls to expand() and other memory - allocations. Free'd at end of this function. - */ - void *context; - /* Counter on the number of arguments this function has encountered so far. Is set to -1 when the count is unknown, i.e. after @@ -2828,7 +2816,6 @@ int parser_t::test( const wchar_t * buff, } - context = halloc( 0, 0 ); current_tokenizer = &tok; for( tok_init( &tok, buff, 0 ); @@ -3519,9 +3506,7 @@ int parser_t::test( const wchar_t * buff, /* Cleanup */ - - halloc_free( context ); - + tok_destroy( &tok ); current_tokenizer=previous_tokenizer; diff --git a/path.cpp b/path.cpp index cffa7bb79..bac23c745 100644 --- a/path.cpp +++ b/path.cpp @@ -15,8 +15,6 @@ #include "common.h" #include "env.h" #include "wutil.h" -#include "halloc.h" -#include "halloc_util.h" #include "path.h" #include "expand.h" diff --git a/path.h b/path.h index b46eff431..60496e35a 100644 --- a/path.h +++ b/path.h @@ -27,7 +27,6 @@ bool path_get_config(wcstring &path); Finds the full path of an executable in a newly allocated string. \param cmd The name of the executable. - \param context the halloc context to use for memory allocations \return 0 if the command can not be found, the path of the command otherwise. The result should be freed with free(). */ wchar_t *path_get_path( const wchar_t *cmd ); diff --git a/proc.cpp b/proc.cpp index 45badb72e..76fb7a694 100644 --- a/proc.cpp +++ b/proc.cpp @@ -72,8 +72,7 @@ Some of the code in this file is based on code from the Glibc manual. #include "signal.h" #include "event.h" -#include "halloc.h" -#include "halloc_util.h" +#include #include "output.h" /** @@ -132,11 +131,10 @@ static string_buffer_t event_status; /** A stack containing the values of is_interactive. Used by proc_push_interactive and proc_pop_interactive. */ -static array_list_t *interactive_stack; +static std::deque interactive_stack; void proc_init() { - interactive_stack = al_halloc( global_context ); proc_push_interactive( 0 ); event.arguments.reset(new wcstring_list_t); sb_init( &event_pid ); @@ -179,8 +177,7 @@ void job_promote(job_t *job) void job_free( job_t * j ) { job_remove( j ); - j->~job_t(); - halloc_free( j ); + delete j; } void process_t::free_argv(void) { @@ -239,8 +236,7 @@ job_t *job_create() while( job_get( free_id ) != 0 ) free_id++; - void *buff = halloc( 0, sizeof(job_t) ); - job_t *res = new (buff) job_t(free_id); + job_t *res = new job_t(free_id); job_list().push_front(res); job_set_flag( res, @@ -1254,7 +1250,7 @@ void proc_sanity_check() void proc_push_interactive( int value ) { int old = is_interactive; - al_push_long( interactive_stack, (long)is_interactive ); + interactive_stack.push_back(is_interactive); is_interactive = value; if( old != value ) signal_set_handlers(); @@ -1263,7 +1259,8 @@ void proc_push_interactive( int value ) void proc_pop_interactive() { int old = is_interactive; - is_interactive= (int)al_pop_long(interactive_stack); + is_interactive= interactive_stack.back(); + interactive_stack.pop_back(); if( is_interactive != old ) signal_set_handlers(); } diff --git a/wildcard.cpp b/wildcard.cpp index b2b016301..9f8bfc259 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -31,7 +31,6 @@ wildcards using **. #include "reader.h" #include "expand.h" #include "exec.h" -#include "halloc_util.h" #include /** diff --git a/wutil.cpp b/wutil.cpp index b486dc8ef..e552df61f 100644 --- a/wutil.cpp +++ b/wutil.cpp @@ -29,8 +29,6 @@ #include "common.h" #include "wutil.h" -#include "halloc.h" -#include "halloc_util.h" typedef std::string cstring; @@ -337,27 +335,18 @@ const wchar_t *wgettext( const wchar_t *in ) return wres; } -wchar_t *wgetenv( const wchar_t *name ) +const wchar_t *wgetenv( const wchar_t *name ) { + ASSERT_IS_MAIN_THREAD(); cstring name_narrow = wcs2string(name); char *res_narrow = getenv( name_narrow.c_str() ); - static string_buffer_t *out = 0; + static wcstring out; if( !res_narrow ) return 0; - if( !out ) - { - out = sb_halloc( global_context ); - } - else - { - sb_clear( out ); - } - - sb_printf( out, L"%s", res_narrow ); - - return (wchar_t *)out->buff; + out = format_string(L"%s", res_narrow); + return out.c_str(); } diff --git a/wutil.h b/wutil.h index c043829be..c462b03c8 100644 --- a/wutil.h +++ b/wutil.h @@ -133,7 +133,7 @@ const wchar_t *wgettext( const wchar_t *in ); /** Wide character version of getenv */ -wchar_t *wgetenv( const wchar_t *name ); +const wchar_t *wgetenv( const wchar_t *name ); /** Wide character version of mkdir