Example #1
0
VIOAPI  VIO_BOOL  unrecord_ptr_alloc_check(
    void     *ptr,
    VIO_STR   source_file,
    int      line_number )
{
    VIO_BOOL  was_previously_alloced;
    VIO_STR   orig_source;
    int      orig_line;
    int      sequence_number;

    was_previously_alloced = TRUE;

    if( alloc_checking_enabled() )
    {
        check_initialized_alloc_list( &alloc_list );

        if( ptr == (void *) 0 )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": Tried to free a NIL pointer.\n" );
            abort_if_allowed();
            was_previously_alloced = FALSE;
        }
        else if( !remove_ptr_from_alloc_list( &alloc_list, ptr, &orig_source,
                                              &orig_line, &sequence_number ) )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": Tried to free a pointer not alloced.\n" );
            abort_if_allowed();
            was_previously_alloced = FALSE;
        }
    }

    return( was_previously_alloced );
}
Example #2
0
VIOAPI  void  change_ptr_alloc_check(
    void      *old_ptr,
    void      *new_ptr,
    size_t    n_bytes,
    VIO_STR    source_file,
    int       line_number )
{
    VIO_STR         orig_source;
    int            orig_line;
    int            sequence_number;
    skip_entry     *entry;
    update_struct  update_ptrs;

    if( alloc_checking_enabled() )
    {
        check_initialized_alloc_list( &alloc_list );

        if( n_bytes == 0 )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": VIO_Realloc called with zero size.\n" );
            abort_if_allowed();
        }
        else if( !remove_ptr_from_alloc_list( &alloc_list, old_ptr,
                      &orig_source, &orig_line, &sequence_number ) )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": Tried to realloc a pointer not already alloced.\n");
            abort_if_allowed();
        }
        else
        {
            (void) find_pointer_position( &alloc_list, new_ptr, &update_ptrs );

            if( check_overlap( &alloc_list, &update_ptrs, new_ptr, n_bytes,
                               &entry ) )
            {
                print_source_location( source_file, line_number, -1 );
                print_error( 
               ": VIO_Realloc returned a pointer overlapping an existing block:\n");
                print_source_location( entry->source_file, entry->line_number,
                                       entry->sequence_number );
                print_error( "\n" );
                abort_if_allowed();
            }
            else
                insert_ptr_in_alloc_list( &alloc_list,
                       &update_ptrs, new_ptr, n_bytes,
                       orig_source, orig_line, sequence_number );
        }
    }
}
Example #3
0
VIOAPI  void  record_ptr_alloc_check(
    void      *ptr,
    size_t    n_bytes,
    VIO_STR    source_file,
    int       line_number )
{
    update_struct  update_ptrs;
    skip_entry     *entry;

    if( alloc_checking_enabled() )
    {
        check_initialized_alloc_list( &alloc_list );

        if( n_bytes == 0 )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": Alloc called with zero size.\n" );
            abort_if_allowed();
        }
        else if( ptr == (void *) 0 )
        {
            print_source_location( source_file, line_number, -1 );
            print_error( ": Alloc returned a NIL pointer.\n" );
            abort_if_allowed();
        }
        else
        {
            (void) find_pointer_position( &alloc_list, ptr, &update_ptrs );

            if( check_overlap( &alloc_list, &update_ptrs, ptr, n_bytes, &entry))
            {
                print_source_location( source_file, line_number, -1 );
                print_error( 
                 ": Alloc returned a pointer overlapping an existing block:\n"
                 );
                print_source_location( entry->source_file, entry->line_number,
                                       entry->sequence_number );
                print_error( "\n" );
                abort_if_allowed();
            }
            else
                insert_ptr_in_alloc_list( &alloc_list,
                           &update_ptrs, ptr, n_bytes,
                           source_file, line_number,
                           get_current_sequence_number() );
        }
    }
}
Example #4
0
File: print.c Project: BIC-MNI/minc
VIOAPI  void   handle_internal_error( char  str[] )
{
    print_error( "Internal error:  %s\n", str );
    abort_if_allowed();
}