ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/include/balloc.h
Revision: 1007
Committed: Tue Sep 1 15:25:26 2009 UTC (16 years, 10 months ago) by michael
Content type: text/x-chdr
File size: 2689 byte(s)
Log Message:
- continue doxyfying sources

File Contents

# Content
1 /*
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 * \version $Id$
25 * \todo Get rid of all typedefs in this file
26 */
27
28 #ifndef INCLUDED_balloc_h
29 #define INCLUDED_balloc_h
30
31 #include "config.h"
32 #include "client.h"
33 #include "tools.h"
34 #include "memory.h"
35 #include "ircd_defs.h"
36
37
38 /*! \brief Block contains status information for
39 * an allocated block in our heap.
40 */
41 struct Block
42 {
43 int freeElems; /*!< Number of available elems */
44 size_t alloc_size; /*!< Size of data space for each block */
45 struct Block* next; /*!< Next in our chain of blocks */
46 void* elems; /*!< Points to allocated memory */
47 dlink_list free_list; /*!< Chain of free memory blocks */
48 };
49
50 typedef struct Block Block;
51
52 struct MemBlock
53 {
54 dlink_node self; /*!< Node for linking into free_list */
55 Block *block; /*!< Which block we belong to */
56 };
57 typedef struct MemBlock MemBlock;
58
59 /*! \brief BlockHeap contains the information for the root node of the
60 * memory heap.
61 */
62 struct BlockHeap
63 {
64 size_t elemSize; /*!< Size of each element to be stored */
65 int elemsPerBlock; /*!< Number of elements per block */
66 int blocksAllocated; /*!< Number of blocks allocated */
67 int freeElems; /*!< Number of free elements */
68 Block* base; /*!< Pointer to first block */
69 const char *name; /*!< Name of the heap */
70 struct BlockHeap *next; /*!< Pointer to next heap */
71 };
72
73 typedef struct BlockHeap BlockHeap;
74
75
76 extern int BlockHeapFree(BlockHeap *, void *);
77 extern void * BlockHeapAlloc(BlockHeap *);
78
79 extern BlockHeap* BlockHeapCreate(const char *const, size_t, int);
80 extern int BlockHeapDestroy(BlockHeap *);
81 extern void initBlockHeap(void);
82 extern void block_heap_report_stats(struct Client *);
83 #endif /* INCLUDED_balloc_h */

Properties

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