File size: 8,375 Bytes
10f2621 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | /**
* @defgroup Vmem Vmem class
* @brief This class provides a safe logged version of malloc and free.
*
* This class provides a safe logged version of malloc and free, with
* all standard routines supported with Vmem variants.
*/
/**
* @file vmem.h
* @ingroup Vmem
* @brief Class Vmem: A safer, object-oriented, malloc/free object.
* @author Michael Holst
* @note None
* @version $Id: vmem.h,v 1.21 2010/08/12 05:40:36 fetk Exp $
*
* @attention
* @verbatim
*
* MALOC = < Minimal Abstraction Layer for Object-oriented C >
* Copyright (C) 1994-- Michael Holst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @endverbatim
*/
#ifndef _VMEM_H_
#define _VMEM_H_
#include <maloc/maloc_base.h>
/*
* ***************************************************************************
* Class Vmem: Parameters and datatypes
* ***************************************************************************
*/
/**
* @ingroup Vmem
* @author Michael Holst
* @brief Contains public data members for Vmem class
*/
struct sVmem {
char name[VMAX_ARGLEN]; /**< name of class we manage malloc areas for */
size_t mallocBytes; /**< total size of all current malloc areas of class*/
size_t freeBytes; /**< total size of all freed malloc areas of class */
size_t highWater; /**< high-water malloc bytemark for this class */
size_t mallocAreas; /**< total number of individual malloc areas */
};
/**
* @brief Declaration of the Vmem class as the Vmem structure
* @ingroup Vmem
* @author Michael Holst
*/
typedef struct sVmem Vmem;
/*
* ***************************************************************************
* Class Vmem: Inlineable methods (vmem.c)
* ***************************************************************************
*/
#if !defined(VINLINE_MALOC)
#else /* if defined(VINLINE_MALOC) */
#endif /* if !defined(VINLINE_MALOC) */
/*
* ***************************************************************************
* Class Vmem: Non-Inlineable methods (vmem.c)
* ***************************************************************************
*/
/**
* @ingroup Vmem
* @brief Return total of all active Vmem malloc areas (current footprint)
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all active Vmem malloc areas (current footprint)
*/
VEXTERNC size_t Vmem_bytesTotal(void);
/**
* @ingroup Vmem
* @brief Return total of all Vmem malloc allocations
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all Vmem malloc allocations
*/
VEXTERNC size_t Vmem_mallocBytesTotal(void);
/**
* @ingroup Vmem
* @brief Return total of all Vmem free calls
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all Vmem free calls
*/
VEXTERNC size_t Vmem_freeBytesTotal(void);
/**
* @ingroup Vmem
* @brief Return the high-water byte mark (largest footprint)
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return the high-water byte mark (largest footprint)
*/
VEXTERNC size_t Vmem_highWaterTotal(void);
/**
* @ingroup Vmem
* @brief Return total of all active Vmem malloc areas by groups
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all active Vmem malloc areas by groups
*/
VEXTERNC size_t Vmem_mallocAreasTotal(void);
/**
* @ingroup Vmem
* @brief Print current memory statistics for all Vmem malloc/free areas
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return None
*/
VEXTERNC void Vmem_printTotal(void);
/**
* @ingroup Vmem
* @brief Construct the dynamic memory allocation logging object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return Pointer to a newly created Vmem object
* @param name Pointer to the object name
*/
VEXTERNC Vmem* Vmem_ctor(char *name);
/**
* @ingroup Vmem
* @brief Destruct the dynamic memory allocation logging object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return None
* @param thee Pointer to the Vmem object
*/
VEXTERNC void Vmem_dtor(Vmem **thee);
/**
* @ingroup Vmem
* @brief A safe logged version of malloc
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return Void pointer to a new malloc area
* @param thee Pointer to the Vmem object
* @param num number of the allocated address
* @param size size of one allocated address
*/
VEXTERNC void *Vmem_malloc(Vmem *thee, size_t num, size_t size);
/**
* @ingroup Vmem
* @brief A safe logged version of free
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return None
* @param thee Pointer to the Vmem object
* @param num number of the allocated address
* @param size size of one allocated address
* @param ram Pointer to pointer of the reallocated memory
*/
VEXTERNC void Vmem_free(Vmem *thee, size_t num, size_t size, void **ram);
/**
* @ingroup Vmem
* @brief A safe logged version of realloc (usually a bad idea to use this)
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return Void pointer to a new malloc area
* @param thee Pointer to the Vmem object
* @param num number of the allocated address
* @param size size of one allocated address
* @param ram Pointer to pointer of the reallocated memory
* @param newNum number of the reallocated address
*/
VEXTERNC void *Vmem_realloc(Vmem *thee, size_t num, size_t size, void **ram,
size_t newNum);
/**
* @ingroup Vmem
* @brief Return total of all ACTIVE malloc areas used by Vmem object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all ACTIVE malloc areas used by Vmem object
* @param thee Pointer to the Vmem object
*/
VEXTERNC size_t Vmem_bytes(Vmem *thee);
/**
* @ingroup Vmem
* @brief Return total of all mallocs performed by Vmem object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all mallocs performed by Vmem object
* @param thee Pointer to the Vmem object
*/
VEXTERNC size_t Vmem_mallocBytes(Vmem *thee);
/**
* @ingroup Vmem
* @brief Return total of all frees performed by Vmem object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total of all frees performed by Vmem object
* @param thee Pointer to the Vmem object
*/
VEXTERNC size_t Vmem_freeBytes(Vmem *thee);
/**
* @ingroup Vmem
* @brief Return high-water malloc bytemark hit by Vmem object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return high-water malloc bytemark hit by Vmem object
* @param thee Pointer to the Vmem object
*/
VEXTERNC size_t Vmem_highWater(Vmem *thee);
/**
* @ingroup Vmem
* @brief Return total number of individual active malloc areas
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return total number of individual active malloc areas
* @param thee Pointer to the Vmem object
*/
VEXTERNC size_t Vmem_mallocAreas(Vmem *thee);
/**
* @ingroup Vmem
* @brief Print current memory stats associated with this Vmem object
* @author Michael Holst
* @note Class Vmem: Non-Inlineable methods (vmem.c)
* @return None
* @param thee Pointer to the Vmem object
*/
VEXTERNC void Vmem_print(Vmem *thee);
#endif /* _VMEM_H_ */
|