The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/libsa/malloc_unused

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*********************************************************************
    2 * free_all()
    3 *
    4 * Empties all memory regions so that their entire buffer space is
    5 * considered unused. This allows the client to restart without
    6 * having to reallocate memory for the allocator regions, which helps
    7 * performance when this package gets used serially.
    8 *********************************************************************/
    9 __private_extern__
   10 void free_all(void) {
   11     malloc_region * cur_region;
   12 
   13     queue_iterate(&malloc_region_list, cur_region, malloc_region *, links) {
   14 
   15         queue_init(&cur_region->block_list);
   16         cur_region->free_size = cur_region->region_size - sizeof(malloc_region);
   17         cur_region->free_address = &cur_region->buffer;
   18 
   19     }
   20 
   21     queue_init(&sorted_free_block_list);
   22 
   23 #ifdef CLIENT_DEBUG
   24     current_block_total = 0;
   25 #endif /* CLIENT_DEBUG */
   26 
   27     return;
   28 
   29 } /* free_all() */
   30 
   31 
   32 /*********************************************************************
   33 * malloc_size()
   34 *
   35 *********************************************************************/
   36 __private_extern__
   37 size_t malloc_size(void * address) {
   38     malloc_region * found_region = NULL;
   39     malloc_block  * found_block = NULL;
   40 
   41     malloc_find_block(address, &found_block, &found_region);
   42 
   43 
   44    /* If we couldn't find the requested block, 
   45     * the caller is in error so return 0.
   46     */
   47     if (found_block == NULL) {
   48         return 0;
   49         // FIXME: panic?
   50     }
   51 
   52     return (found_block->block_size - sizeof(malloc_block));
   53 
   54 } /* malloc_size() */
   55 
   56 
   57 /*********************************************************************
   58 * malloc_is_valid()
   59 *
   60 *********************************************************************/
   61 __private_extern__
   62 int malloc_is_valid(void * address){
   63     malloc_region * found_region = NULL;
   64     malloc_block  * found_block = NULL;
   65 
   66     malloc_find_block(address, &found_block, &found_region);
   67 
   68     if (found_block != NULL) {
   69         return 1;
   70     } else {
   71         return 0;
   72     }
   73 
   74 } /* malloc_is_valid() */
   75 
   76 

Cache object: 2362c6be87a795a7e708c13625633836


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.