mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:41:42 +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 "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 );
|
||||
|
|
|
@ -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 ) )
|
||||
{
|
||||
|
|
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++ )
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user