mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 10:43:32 +08:00
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
This commit is contained in:
parent
a2cd8c8a8d
commit
b6cd723eb7
23
halloc.c
23
halloc.c
|
@ -15,16 +15,17 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "halloc.h"
|
#include "halloc.h"
|
||||||
|
|
||||||
#define HALLOC_BLOCK_SIZE 256
|
#define HALLOC_BLOCK_SIZE 128
|
||||||
#define HALLOC_SCRAP_SIZE 16
|
#define HALLOC_SCRAP_SIZE 16
|
||||||
|
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
static int child_count=0;
|
static int child_count=0;
|
||||||
static int child_size=0;
|
static int child_size=0;
|
||||||
static int alloc_count =0;
|
static int alloc_count =0;
|
||||||
static int alloc_spill = 0;
|
static int alloc_spill = 0;
|
||||||
static pid_t pid=0;
|
static pid_t pid=0;
|
||||||
static int parent_count=0;
|
static int parent_count=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct halloc
|
typedef struct halloc
|
||||||
{
|
{
|
||||||
|
@ -44,6 +45,7 @@ static void late_free( void *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
static void woot()
|
static void woot()
|
||||||
{
|
{
|
||||||
if( getpid() == pid )
|
if( getpid() == pid )
|
||||||
|
@ -53,6 +55,7 @@ static void woot()
|
||||||
parent_count+alloc_count, (double)alloc_spill/(parent_count+alloc_count) );
|
parent_count+alloc_count, (double)alloc_spill/(parent_count+alloc_count) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void *halloc( void *context, size_t size )
|
void *halloc( void *context, size_t size )
|
||||||
{
|
{
|
||||||
|
@ -61,6 +64,7 @@ void *halloc( void *context, size_t size )
|
||||||
{
|
{
|
||||||
void *res;
|
void *res;
|
||||||
|
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
|
|
||||||
if( !child_count )
|
if( !child_count )
|
||||||
{
|
{
|
||||||
|
@ -70,7 +74,7 @@ void *halloc( void *context, size_t size )
|
||||||
|
|
||||||
child_count++;
|
child_count++;
|
||||||
child_size += size;
|
child_size += size;
|
||||||
|
#endif
|
||||||
parent = halloc_from_data( context );
|
parent = halloc_from_data( context );
|
||||||
if( size <= parent->scratch_free )
|
if( size <= parent->scratch_free )
|
||||||
{
|
{
|
||||||
|
@ -80,11 +84,16 @@ void *halloc( void *context, size_t size )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
alloc_count++;
|
alloc_count++;
|
||||||
|
#endif
|
||||||
|
|
||||||
if( parent->scratch_free < HALLOC_SCRAP_SIZE )
|
if( parent->scratch_free < HALLOC_SCRAP_SIZE )
|
||||||
{
|
{
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
alloc_spill += parent->scratch_free;
|
alloc_spill += parent->scratch_free;
|
||||||
|
#endif
|
||||||
res = calloc( 1, size + HALLOC_BLOCK_SIZE );
|
res = calloc( 1, size + HALLOC_BLOCK_SIZE );
|
||||||
parent->scratch = res + size;
|
parent->scratch = res + size;
|
||||||
parent->scratch_free = HALLOC_BLOCK_SIZE;
|
parent->scratch_free = HALLOC_BLOCK_SIZE;
|
||||||
|
@ -106,8 +115,9 @@ void *halloc( void *context, size_t size )
|
||||||
|
|
||||||
if( !me )
|
if( !me )
|
||||||
return 0;
|
return 0;
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
parent_count++;
|
parent_count++;
|
||||||
|
#endif
|
||||||
me->scratch = ((void *)me) + sizeof(halloc_t) + size;
|
me->scratch = ((void *)me) + sizeof(halloc_t) + size;
|
||||||
me->scratch_free = HALLOC_BLOCK_SIZE;
|
me->scratch_free = HALLOC_BLOCK_SIZE;
|
||||||
|
|
||||||
|
@ -138,8 +148,9 @@ void halloc_free( void *context )
|
||||||
|
|
||||||
me = halloc_from_data( context );
|
me = halloc_from_data( context );
|
||||||
|
|
||||||
|
#ifdef HALLOC_DEBUG
|
||||||
alloc_spill += me->scratch_free;
|
alloc_spill += me->scratch_free;
|
||||||
|
#endif
|
||||||
for( i=0; i<al_get_count(&me->children); i+=2 )
|
for( i=0; i<al_get_count(&me->children); i+=2 )
|
||||||
{
|
{
|
||||||
void (*func)(void *) = (void (*)(void *))al_get( &me->children, i );
|
void (*func)(void *) = (void (*)(void *))al_get( &me->children, i );
|
||||||
|
|
|
@ -130,10 +130,10 @@ void highlight_shell( wchar_t * buff,
|
||||||
/*
|
/*
|
||||||
Command. First check that the command actually exists.
|
Command. First check that the command actually exists.
|
||||||
*/
|
*/
|
||||||
wchar_t *cmd =
|
wchar_t *cmd = expand_one( 0,
|
||||||
(last_type == TOK_STRING) ?
|
wcsdup(tok_last( &tok )),
|
||||||
expand_one( 0, wcsdup(tok_last( &tok )),EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES) :
|
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
||||||
wcsdup(tok_last( &tok ));
|
|
||||||
if( cmd == 0 )
|
if( cmd == 0 )
|
||||||
{
|
{
|
||||||
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
|
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
|
||||||
|
@ -145,7 +145,6 @@ void highlight_shell( wchar_t * buff,
|
||||||
int is_subcommand = 0;
|
int is_subcommand = 0;
|
||||||
int mark = tok_get_pos( &tok );
|
int mark = tok_get_pos( &tok );
|
||||||
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_COMMAND;
|
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_COMMAND;
|
||||||
|
|
||||||
|
|
||||||
if( parser_is_subcommand( cmd ) )
|
if( parser_is_subcommand( cmd ) )
|
||||||
{
|
{
|
||||||
|
|
2
kill.c
2
kill.c
|
@ -136,7 +136,7 @@ static void kill_check_x_buffer()
|
||||||
|
|
||||||
for( i=0; i<al_get_count( &list ); i++ )
|
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 )
|
if( i==0 )
|
||||||
{
|
{
|
||||||
new_cut_buffer = next_line;
|
new_cut_buffer = next_line;
|
||||||
|
|
|
@ -489,7 +489,7 @@ int parse_util_load( const wchar_t *cmd,
|
||||||
hash_init( all_loaded, &hash_wcs_func, &hash_wcs_cmp );
|
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 )
|
if( !loaded )
|
||||||
{
|
{
|
||||||
|
|
1
reader.c
1
reader.c
|
@ -1417,6 +1417,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||||
sb_init( &cmd );
|
sb_init( &cmd );
|
||||||
sb_printf( &cmd,
|
sb_printf( &cmd,
|
||||||
L"fish_pager %d %ls",
|
L"fish_pager %d %ls",
|
||||||
|
// L"valgrind --track-fds=yes --log-file=pager.txt ./fish_pager %d %ls",
|
||||||
is_quoted,
|
is_quoted,
|
||||||
prefix_esc );
|
prefix_esc );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user