Hosted by the courtesy of  
 GitHub 
The stars ASAP english francais spanish arab
Durée du voyage intersidéral francais
Résolutions de l'ONU en HTML francais
Bussard Ramjet english francais
DWARF : dwarf2xml english
ELF : libelf examples english
Code presentation : ctoohtml english

To rings Doc++

File Index

All Tags

Tags by File

Tags referrers

file: ring_alloc_test.c


  1 /*
  2 * Copyright (C) 2008-2009 by Emmanuel Azencot under the GNU LGPL
  3 * license version 2.0 or 2.1.  You should have received a copy of the
  4 * LGPL license along with this library if you did not you can find it
  5 * at http://www.gnu.org/.
  6 */

  7 /*
  8 * Azencot : Sat Dec  6 11:14:08 CET 2008
  9 *  Creation
 10 */

 11 #include <stdio.h>
 12 #include <errno.h>
 13 #include <assert.h>
 14
 15 #include "ring.h"
 16 #include "ring_alloc.h"
 17
 18 unsigned char /*X*/ region[0x20000];
 19
 20 int /*X*/ main(int argc, char *argv[]) {
 21   to_mempool mempool;
 22   struct s_mempool_info info;
 23   struct s_mempool_stats stats;
 24   void *mem;
 25
 26 {
 27   void *mem[6];
 28   int size, i;
 29   assert ( !f_mempool_info(&info) );
 30   size = info.pool_head_size + 5*(info.pool_head_size +40);
 31   assert( (mempool = f_mempool_init(size, region)) ) ;
 32   for ( i = 0; i < 5; ++i ) {
 33      assert( (mem[i] = f_mempool_malloc(mempool, 40)) );
 34   }
 35   assert( !f_mempool_free(mempool, mem[1]) );
 36   assert( !f_mempool_free(mempool, mem[3]) );
 37   assert( !f_mempool_free(mempool, mem[5]) );
 38   assert( !f_mempool_free(mempool, mem[0]) );
 39   assert( !f_mempool_free(mempool, mem[2]) );
 40   assert( !f_mempool_free(mempool, mem[4]) );
 41 }
 42   assert( !(mempool = f_mempool_init(0, region)) && errno == ENOMEM) ;
 43   assert( !(mempool = f_mempool_init(16, region)) && errno == ENOMEM) ;
 44   assert( !(mempool = f_mempool_init(200, 0)) && errno == EFAULT) ;
 45   
 46   assert ( !f_mempool_info(&info) );
 47   assert( info.options.stats && info.options.chk_pool && info.options.chk_blk );
 48   assert( info.pool_head_size >= 3*sizeof(void *) );
 49   assert( info.block_head_size >= 1*sizeof(void *) );
 50 // printf("pool_head_size = %d, block_head_size = %d\n", info.pool_head_size, info.block_head_size);
 51   assert( !(mempool = f_mempool_init(info.pool_head_size +info.block_head_size -1, region)) && errno == ENOMEM) ;
 52   assert( (mempool = f_mempool_init(info.pool_head_size +info.block_head_size, region)) ) ;
 53   assert( f_mempool_stats(mempool, &stats) == 0 ) ;
 54   assert( (mem = f_mempool_malloc(mempool, 0)) );
 55   assert( f_mempool_free(mempool, (void *)0x30) == -1 && errno == ENOTDIR);
 56   errno = 0; assert( !f_mempool_free(mempool, 0) && errno == 0);
 57   assert( !f_mempool_free(mempool, mem) );
 58   assert( f_mempool_free(mempool, mem) == -1 && errno == ENOENT);
 59   return 0;
 60 }


To rings Doc++

File Index

All Tags

Tags by File

Tags referrers

C to HTML Conversion by ctoohtml

Hosted by the courtesy of  
 GitHub 
The stars ASAP english francais spanish
Durée du voyage intersidéral francais
Résolutions de l'ONU en HTML francais
Bussard Ramjet english francais
DWARF : dwarf2xml english
ELF : libelf examples english
Code presentation : ctoohtml english