diff --git a/halloc.c b/halloc.c index 3779f99b6..996a4cb56 100644 --- a/halloc.c +++ b/halloc.c @@ -15,16 +15,17 @@ #include "common.h" #include "halloc.h" -#define HALLOC_BLOCK_SIZE 256 +#define HALLOC_BLOCK_SIZE 128 #define HALLOC_SCRAP_SIZE 16 +#ifdef HALLOC_DEBUG static int child_count=0; static int child_size=0; static int alloc_count =0; static int alloc_spill = 0; static pid_t pid=0; static int parent_count=0; - +#endif typedef struct halloc { @@ -44,6 +45,7 @@ static void late_free( void *data) { } +#ifdef HALLOC_DEBUG static void woot() { if( getpid() == pid ) @@ -53,6 +55,7 @@ static void woot() parent_count+alloc_count, (double)alloc_spill/(parent_count+alloc_count) ); } } +#endif void *halloc( void *context, size_t size ) { @@ -61,6 +64,7 @@ void *halloc( void *context, size_t size ) { void *res; +#ifdef HALLOC_DEBUG if( !child_count ) { @@ -70,7 +74,7 @@ void *halloc( void *context, size_t size ) child_count++; child_size += size; - +#endif parent = halloc_from_data( context ); if( size <= parent->scratch_free ) { @@ -80,11 +84,16 @@ void *halloc( void *context, size_t 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 = calloc( 1, size + HALLOC_BLOCK_SIZE ); parent->scratch = res + size; parent->scratch_free = HALLOC_BLOCK_SIZE; @@ -106,8 +115,9 @@ void *halloc( void *context, size_t size ) if( !me ) return 0; +#ifdef HALLOC_DEBUG parent_count++; - +#endif me->scratch = ((void *)me) + sizeof(halloc_t) + size; me->scratch_free = HALLOC_BLOCK_SIZE; @@ -138,8 +148,9 @@ void halloc_free( void *context ) 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 ); diff --git a/highlight.c b/highlight.c index 1a7156d6f..51f336654 100644 --- a/highlight.c +++ b/highlight.c @@ -130,10 +130,10 @@ void highlight_shell( wchar_t * buff, /* Command. First check that the command actually exists. */ - wchar_t *cmd = - (last_type == TOK_STRING) ? - expand_one( 0, wcsdup(tok_last( &tok )),EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES) : - wcsdup(tok_last( &tok )); + wchar_t *cmd = expand_one( 0, + wcsdup(tok_last( &tok )), + EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES); + if( cmd == 0 ) { color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; @@ -145,7 +145,6 @@ void highlight_shell( wchar_t * buff, int is_subcommand = 0; int mark = tok_get_pos( &tok ); color[ tok_get_pos( &tok ) ] = HIGHLIGHT_COMMAND; - if( parser_is_subcommand( cmd ) ) { diff --git a/kill.c b/kill.c index f3c07e195..b4a2a7d75 100644 --- a/kill.c +++ b/kill.c @@ -136,7 +136,7 @@ static void kill_check_x_buffer() for( i=0; i