diff --git a/builtin.cpp b/builtin.cpp index 4c55b0959..c880d1597 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -59,8 +59,6 @@ #include "signal.h" #include "exec.h" #include "highlight.h" -#include "halloc.h" -#include "halloc_util.h" #include "parse_util.h" #include "parser_keywords.h" #include "expand.h" diff --git a/exec.cpp b/exec.cpp index d987a0c7e..2d5021f54 100644 --- a/exec.cpp +++ b/exec.cpp @@ -46,8 +46,6 @@ #include "expand.h" #include "signal.h" -#include "halloc.h" -#include "halloc_util.h" #include "parse_util.h" /** diff --git a/halloc_util.cpp b/halloc_util.cpp index 45fb4b3a8..75a7f9235 100644 --- a/halloc_util.cpp +++ b/halloc_util.cpp @@ -74,19 +74,6 @@ void *halloc_register( void *context, void *data ) return data; } -wchar_t *halloc_wcsdup( void *context, const wchar_t *in ) -{ - size_t len=wcslen(in); - wchar_t *out = (wchar_t *)halloc( context, sizeof( wchar_t)*(len+1)); - - if( out == 0 ) - { - DIE_MEM(); - } - memcpy( out, in, sizeof( wchar_t)*(len+1)); - return out; -} - wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c ) { wchar_t *res = (wchar_t *)halloc( context, sizeof(wchar_t)*(c+1) ); diff --git a/halloc_util.h b/halloc_util.h index 680cffe76..109277429 100644 --- a/halloc_util.h +++ b/halloc_util.h @@ -51,12 +51,6 @@ void halloc_register_function_void( void *context, void (*func)() ); */ void *halloc_register( void *context, void *data ); -/** - Make a copy of the specified string using memory allocated using - halloc and the specified context -*/ -wchar_t *halloc_wcsdup( void *context, const wchar_t *str ); - /** Make a copy of the specified substring using memory allocated using halloc and the specified context diff --git a/parser.cpp b/parser.cpp index 1263a7dde..be5103318 100644 --- a/parser.cpp +++ b/parser.cpp @@ -1245,7 +1245,7 @@ void parser_t::parse_job_argument_list( process_t *p, int matched_wildcard = 0, unmatched_wildcard = 0; - wchar_t *unmatched = 0; + wcstring unmatched; int unmatched_pos=0; /* @@ -1374,9 +1374,9 @@ void parser_t::parse_job_argument_list( process_t *p, case EXPAND_WILDCARD_NO_MATCH: { unmatched_wildcard = 1; - if( !unmatched ) + if( unmatched.empty() ) { - unmatched = halloc_wcsdup( j, tok_last( tok )); + unmatched = tok_last(tok); unmatched_pos = tok_get_pos( tok ); } @@ -1589,7 +1589,7 @@ void parser_t::parse_job_argument_list( process_t *p, { int tmp; - debug( 1, WILDCARD_ERR_MSG, unmatched ); + debug( 1, WILDCARD_ERR_MSG, unmatched.c_str() ); tmp = current_tokenizer_pos; current_tokenizer_pos = unmatched_pos; diff --git a/reader.cpp b/reader.cpp index a085970f8..f5b256f3e 100644 --- a/reader.cpp +++ b/reader.cpp @@ -101,8 +101,6 @@ commence. #include "output.h" #include "signal.h" #include "screen.h" -#include "halloc.h" -#include "halloc_util.h" #include "iothread.h" #include "intern.h" @@ -1338,19 +1336,15 @@ static void reader_flash() exact replacement, e.g. if the COMPLETE_DONT_ESCAPE flag is set. */ -int reader_can_replace( const wchar_t *in, int flags ) +static int reader_can_replace( const wcstring &in, int flags ) { - const wchar_t * str = in; + const wchar_t * str = in.c_str(); if( flags & COMPLETE_DONT_ESCAPE ) { return 1; } - - - CHECK( in, 1 ); - /* Test characters that have a special meaning in any character position */ @@ -1382,20 +1376,17 @@ int reader_can_replace( const wchar_t *in, int flags ) static int handle_completions( std::vector &comp ) { - void *context = 0; wchar_t *base = 0; int len = 0; int done = 0; int count = 0; int flags=0; const wchar_t *begin, *end, *buff = data->command_line.c_str(); - wchar_t *tok; parse_util_token_extent( buff, data->buff_pos, &begin, 0, 0, 0 ); end = buff+data->buff_pos; - context = halloc( 0, 0 ); - tok = halloc_wcsndup( context, begin, end-begin ); + const wcstring tok(begin, end - begin); /* Check trivial cases @@ -1494,7 +1485,7 @@ static int handle_completions( std::vector &comp ) if( begin ) { - int offset = wcslen( tok ); + int offset = tok.size(); count = 0; @@ -1601,11 +1592,7 @@ static int handle_completions( std::vector &comp ) s_reset( &data->screen, 1 ); reader_repaint(); - } - - - halloc_free( context ); - + } return len;