group/pintos/src/lib/kernel/bitmap.c
/* Creates and returns a pointer to a newly allocated bitmap with room for
   BIT_CNT (or more) bits.  Returns a null pointer if memory allocation fails.
   The caller is responsible for freeing the bitmap, with bitmap_destroy(),
   when it is no longer needed. */
Creates and returns a pointer to a newly allocated bitmap with room for
BIT_CNT (or more) bits.  Returns a null pointer if memory allocation fails.
The caller is responsible for freeing the bitmap, with bitmap_destroy(),
when it is no longer needed.
Creates and returns a pointer to a newly allocated bitmap with room for BIT_CNT ( or more ) bits . Returns a null pointer if memory allocation fails . The caller is responsible for freeing the bitmap with bitmap_destroy () when it is no longer needed .
struct bitmap *
bitmap_create (size_t bit_cnt)
{
  struct bitmap *b = malloc (sizeof *b);
  if (b != NULL)
    {
      b->bit_cnt = bit_cnt;
      b->bits = malloc (byte_cnt (bit_cnt));
      if (b->bits != NULL || bit_cnt == 0)
        {
          bitmap_set_all (b, false);
          return b;
        }
      free (b);
    }
  return NULL;
}
struct bitmap * bitmap_create ( size_t bit_cnt ) { struct bitmap * b = malloc ( sizeof * b ) ; if ( b != NULL ) { b -> bit_cnt = bit_cnt ; b -> bits = malloc ( byte_cnt ( bit_cnt ) ) ; if ( b -> bits != NULL || bit_cnt == 0 ) { bitmap_set_all ( b , false ) ; return b ; } free ( b ) ; } return NULL ; }
Creates and returns a pointer to a newly allocated bitmap with room for
BIT_CNT (or more) bits.
Creates and returns a pointer to a newly allocated bitmap with room for BIT_CNT ( or more ) bits .