ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.3/include/balloc.h
Revision: 1011
Committed: Fri Sep 18 10:14:09 2009 UTC (16 years, 10 months ago) by michael
Content type: text/x-chdr
Original Path: ircd-hybrid-7.2/include/balloc.h
File size: 2651 byte(s)
Log Message:
- move list manipulation routines from tools.c to list.c
- mem_frob() goes to memory.c
- sort out redundant/unneeded header includes

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     *
4     * Copyright (C) 2002 by the past and present ircd coders, and others.
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * USA
20     */
21    
22     /*! \file balloc.h
23     * \brief A block allocator
24 knight 31 * \version $Id$
25 adx 30 * \todo Get rid of all typedefs in this file
26     */
27    
28     #ifndef INCLUDED_balloc_h
29     #define INCLUDED_balloc_h
30    
31 michael 912 #include "config.h"
32 adx 30 #include "client.h"
33     #include "ircd_defs.h"
34    
35    
36     /*! \brief Block contains status information for
37     * an allocated block in our heap.
38     */
39 michael 1007 struct Block
40     {
41 adx 30 int freeElems; /*!< Number of available elems */
42     size_t alloc_size; /*!< Size of data space for each block */
43     struct Block* next; /*!< Next in our chain of blocks */
44     void* elems; /*!< Points to allocated memory */
45     dlink_list free_list; /*!< Chain of free memory blocks */
46     };
47    
48     typedef struct Block Block;
49    
50 michael 1007 struct MemBlock
51     {
52     dlink_node self; /*!< Node for linking into free_list */
53 adx 30 Block *block; /*!< Which block we belong to */
54     };
55 michael 1011
56 adx 30 typedef struct MemBlock MemBlock;
57    
58     /*! \brief BlockHeap contains the information for the root node of the
59     * memory heap.
60     */
61 michael 1007 struct BlockHeap
62     {
63 adx 30 size_t elemSize; /*!< Size of each element to be stored */
64     int elemsPerBlock; /*!< Number of elements per block */
65     int blocksAllocated; /*!< Number of blocks allocated */
66     int freeElems; /*!< Number of free elements */
67     Block* base; /*!< Pointer to first block */
68     const char *name; /*!< Name of the heap */
69     struct BlockHeap *next; /*!< Pointer to next heap */
70     };
71    
72     typedef struct BlockHeap BlockHeap;
73    
74    
75     extern int BlockHeapFree(BlockHeap *, void *);
76     extern void * BlockHeapAlloc(BlockHeap *);
77    
78     extern BlockHeap* BlockHeapCreate(const char *const, size_t, int);
79     extern int BlockHeapDestroy(BlockHeap *);
80     extern void initBlockHeap(void);
81     extern void block_heap_report_stats(struct Client *);
82     #endif /* INCLUDED_balloc_h */

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision