diff options
author | 2006-02-12 23:18:46 +1000 | |
---|---|---|
committer | 2006-02-12 23:18:46 +1000 | |
commit | b6cd723eb7cd6586063e7d5c35e63828c9310906 (patch) | |
tree | e16e5711898625f7208b3b8eff92b7ea6f93843d | |
parent | a2cd8c8a8dfc8b3acc208bb1113260cb69ca03d1 (diff) |
Fix a few compiler warnings, add halloc debug output on exit if HALLOC_DEBUG is defined and other minor tweaks
darcs-hash:20060212131846-ac50b-128685d1c043697768be70631c736567544abf2c.gz
-rw-r--r-- | halloc.c | 23 | ||||
-rw-r--r-- | highlight.c | 9 | ||||
-rw-r--r-- | kill.c | 2 | ||||
-rw-r--r-- | parse_util.c | 2 | ||||
-rw-r--r-- | reader.c | 1 |
5 files changed, 24 insertions, 13 deletions
@@ -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; i<al_get_count(&me->children); i+=2 ) { void (*func)(void *) = (void (*)(void *))al_get( &me->children, i ); diff --git a/highlight.c b/highlight.c index 1a7156d6..51f33665 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 ) ) { @@ -136,7 +136,7 @@ static void kill_check_x_buffer() for( i=0; i<al_get_count( &list ); i++ ) { - wchar_t *next_line = escape( (wchar_t *)al_get( &list, i ), 0); + wchar_t *next_line = escape( (wchar_t *)al_get( &list, i ), 0 ); if( i==0 ) { new_cut_buffer = next_line; diff --git a/parse_util.c b/parse_util.c index dbcffdb2..fd645ce7 100644 --- a/parse_util.c +++ b/parse_util.c @@ -489,7 +489,7 @@ int parse_util_load( const wchar_t *cmd, hash_init( all_loaded, &hash_wcs_func, &hash_wcs_cmp ); } - loaded = hash_get( all_loaded, path_var ); + loaded = (hash_table_t *)hash_get( all_loaded, path_var ); if( !loaded ) { @@ -1417,6 +1417,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp ) sb_init( &cmd ); sb_printf( &cmd, L"fish_pager %d %ls", +// L"valgrind --track-fds=yes --log-file=pager.txt ./fish_pager %d %ls", is_quoted, prefix_esc ); |