Thanks to visit codestin.com
Credit goes to github.com

Skip to content

unnecessary calculation in function s_get_next_block of salloc.c #167

@Changqing-JING

Description

@Changqing-JING

static char* s_get_next_block( char* ptr )
{
return ( char* )( ( ( u32 )ptr & 0x7FFFFFFF ) << DYN_SIZE_MULT_SHIFT );
}

This function is made of two calculations:

  1. set the highest bit as 0.
  2. left shift 3 bits

But if a number is left shift for 3 bits, the highest bit will be overflow. So the result is independent of whether the highest bit is 0 or 1. The first calculation can be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions