home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #1 / MONSTER.ISO / prog / gen / regex011.taz / regex011 / regex-0.11 / test / malloc-test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-10  |  929 b   |  48 lines

  1.  
  2.  
  3. typedef struct {
  4.    unsigned *bits;
  5.    unsigned size;
  6. } bits_list_type;
  7.  
  8. #define BYTEWIDTH  8
  9. #define NULL 0
  10.  
  11. #define BITS_BLOCK_SIZE (sizeof (unsigned) * BYTEWIDTH)
  12. #define BITS_BLOCK(position) ((position) / BITS_BLOCK_SIZE)
  13. #define BITS_MASK(position) (1 << ((position) % BITS_BLOCK_SIZE))
  14.  
  15. static unsigned
  16. init_bits_list (bits_list_ptr)
  17.   bits_list_type *bits_list_ptr;
  18. {
  19.   bits_list_ptr->bits = NULL;
  20.   bits_list_ptr->bits = (unsigned *) malloc (sizeof (unsigned));
  21.  
  22.   if (bits_list_ptr->bits == NULL)
  23.     return 0;
  24.  
  25.   bits_list_ptr->bits[0] = (unsigned)0;
  26.   bits_list_ptr->size = BITS_BLOCK_SIZE;
  27.  
  28.   return 1;
  29. }
  30.  
  31.  
  32. main()
  33. {
  34.   bits_list_type dummy;
  35.   bits_list_type dummy_1;
  36.   bits_list_type dummy_2;
  37.   bits_list_type dummy_3;
  38.  
  39.   init_bits_list (&dummy);
  40. printf("init 1\n");
  41.   init_bits_list (&dummy_1);
  42. printf("init 2\n");
  43.   init_bits_list (&dummy_2);
  44. printf("init 3\n");
  45.   init_bits_list (&dummy_3);
  46. printf("init 4\n");
  47. }
  48.