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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
|
/*
* Defines for low level memory management routines
*
* Copyright 2000 by Gray Watson
*
* This file is part of the dmalloc package.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Gray Watson not be used in advertising
* or publicity pertaining to distribution of the document or software
* without specific, written prior permission.
*
* Gray Watson makes no representations about the suitability of the
* software described herein for any purpose. It is provided "as is"
* without express or implied warranty.
*
* The author may be contacted via http://dmalloc.com/
*
* $Id: chunk.h,v 1.72 2007/03/23 13:33:06 gray Exp $
*/
#ifndef __CHUNK_H__
#define __CHUNK_H__
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/* limit in how much memory we are allowed to allocate */
extern
unsigned long _dmalloc_memory_limit;
/* total number of bytes that the heap has allocated */
extern
unsigned long _dmalloc_alloc_total;
/*
* int _dmalloc_chunk_startup
*
* DESCRIPTION:
*
* Startup the low level malloc routines.
*
* RETURNS:
*
* Success - 1
*
* Failure - 0
*
* ARGUMENTS:
*
* None.
*/
extern
int _dmalloc_chunk_startup(void);
/*
* int _dmalloc_chunk_tag_pnt
*
* DESCRIPTION:
*
* Look for a specific address in the skip list. If it exist
* set the file and line fields to given value. Handy for tagging
* pointers from external libraries whithout dmalloc macros.
*
* RETURNS:
*
* Success - 1
*
* Failure - 0
*
* ARGUMENTS:
*
* user_pnt -> Address we are looking for.
*
* file -> should typically point to filename of source file. String is _not_
* copied.
*
* line -> source file line number
*
*/
extern
int _dmalloc_chunk_tag_pnt(const void * user_pnt, char *file, int line);
/*
* char *_dmalloc_chunk_desc_pnt
*
* DESCRIPTION:
*
* Write into a buffer a pointer description with file and
* line-number.
*
* RETURNS:
*
* Pointer to buffer 1st argument.
*
* ARGUMENTS:
*
* buf <-> Passed in buffer which will be filled with a description of
* the pointer.
*
* buf_size -> Size of the buffer in bytes.
*
* file -> File name, return address, or NULL.
*
* line -> Line number or 0.
*/
extern
char *_dmalloc_chunk_desc_pnt(char *buf, const int buf_size,
const char *file, const unsigned int line);
/*
* int _dmalloc_chunk_read_info
*
* DESCRIPTION:
*
* Return some information associated with a pointer.
*
* RETURNS:
*
* Success - 1 pointer is okay
*
* Failure - 0 problem with pointer
*
* ARGUMENTS:
*
* user_pnt -> Pointer we are checking.
*
* where <- Where the check is being made from.
*
* user_size_p <- Pointer to an unsigned int which, if not NULL, will
* be set to the size of bytes that the user requested.
*
* alloc_size_p <- Pointer to an unsigned int which, if not NULL, will
* be set to the total given size of bytes including block overhead.
*
* file_p <- Pointer to a character pointer which, if not NULL, will
* be set to the file where the pointer was allocated.
*
* line_p <- Pointer to a character pointer which, if not NULL, will
* be set to the line-number where the pointer was allocated.
*
* ret_attr_p <- Pointer to a void pointer, if not NULL, will be set
* to the return-address where the pointer was allocated.
*
* seen_cp <- Pointer to an unsigned long which, if not NULL, will be
* set to the number of times the pointer has been "seen".
*
* used_p <- Pointer to an unsigned long which, if not NULL, will be
* set to the last time the pointer was "used".
*
* valloc_bp <- Pointer to an integer which, if not NULL, will be set
* to 1 if the pointer was allocated with valloc otherwise 0.
*
* fence_bp <- Pointer to an integer which, if not NULL, will be set
* to 1 if the pointer has the fence bit set otherwise 0.
*/
extern
int _dmalloc_chunk_read_info(const void *user_pnt, const char *where,
unsigned int *user_size_p,
unsigned int *alloc_size_p, char **file_p,
unsigned int *line_p, void **ret_attr_p,
unsigned long **seen_cp,
unsigned long *used_p, int *valloc_bp,
int *fence_bp);
/*
* int _dmalloc_chunk_heap_check
*
* DESCRIPTION:
*
* Run extensive tests on the entire heap.
*
* RETURNS:
*
* Success - 1 if the heap is okay
*
* Failure - 0 if a problem was detected
*
* ARGUMENTS:
*
* None.
*/
extern
int _dmalloc_chunk_heap_check(void);
/*
* int _dmalloc_chunk_pnt_check
*
* DESCRIPTION:
*
* Run extensive tests on a pointer.
*
* RETURNS:
*
* Success - 1 if the pointer is okay
*
* Failure - 0 if not
*
* ARGUMENTS:
*
* func -> Function string which is checking the pointer.
*
* user_pnt -> Pointer we are checking.
*
* exact_b -> Set to 1 to find the pointer specifically. Otherwise we
* can find the pointer inside of an allocation.
*
* strlen_b -> Make sure that pnt can hold at least a strlen + 1
* bytes. If 0 then ignore.
*
* min_size -> Make sure that pnt can hold at least that many bytes.
* If 0 then ignore.
*/
extern
int _dmalloc_chunk_pnt_check(const char *func, const void *user_pnt,
const int exact_b, const int strlen_b,
const int min_size);
/*
* void *_dmalloc_chunk_malloc
*
* DESCRIPTION:
*
* Allocate a chunk of memory.
*
* RETURNS:
*
* Success - Valid pointer.
*
* Failure - NULL
*
* ARGUMENTS:
*
* file -> File-name or return-address location of the allocation.
*
* line -> Line-number location of the allocation.
*
* size -> Number of bytes to allocate.
*
* func_id -> Calling function-id as defined in dmalloc.h.
*
* alignment -> If greater than 0 then try to align the returned
* block.
*/
extern
void *_dmalloc_chunk_malloc(const char *file, const unsigned int line,
const unsigned long size, const int func_id,
const unsigned int alignment);
/*
* int _dmalloc_chunk_free
*
* DESCRIPTION:
*
* Free a user pointer from the heap.
*
* RETURNS:
*
* Success - FREE_NOERROR
*
* Failure - FREE_ERROR
*
* ARGUMENTS:
*
* file -> File-name or return-address location of the allocation.
*
* line -> Line-number location of the allocation.
*
* user_pnt -> Pointer we are freeing.
*
* func_id -> Function ID
*/
extern
int _dmalloc_chunk_free(const char *file, const unsigned int line,
void *user_pnt, const int func_id);
/*
* void *_dmalloc_chunk_realloc
*
* DESCRIPTION:
*
* Re-allocate a chunk of memory either shrinking or expanding it.
*
* RETURNS:
*
* Success - Valid pointer.
*
* Failure - NULL
*
* ARGUMENTS:
*
* file -> File-name or return-address location of the allocation.
*
* line -> Line-number location of the allocation.
*
* old_user_pnt -> Old user pointer that we are reallocating.
*
* new_size -> New-size to change the pointer.
*
* func_id -> Calling function-id as defined in dmalloc.h.
*/
extern
void *_dmalloc_chunk_realloc(const char *file, const unsigned int line,
void *old_user_pnt,
const unsigned long new_size,
const int func_id);
/*
* void _dmalloc_chunk_log_stats
*
* DESCRIPTION:
*
* Log general statistics from the heap to the logfile.
*
* RETURNS:
*
* None.
*
* ARGUMENTS:
*
* None.
*/
extern
void _dmalloc_chunk_log_stats(void);
/*
* void _dmalloc_chunk_log_changed
*
* DESCRIPTION:
*
* Log the pointers that has changed since a pointer in time.
*
* RETURNS:
*
* None.
*
* ARGUMENTS:
*
* mark -> Dmalloc counter used to mark a specific time so that
* servers can check on the changed pointers.
*
* log_non_free_b -> If set to 1 then log the new not-freed
* (i.e. used) pointers.
*
* log_free_b -> If set to 1 then log the new freed pointers.
*
* details_b -> If set to 1 then dump the individual pointer entries
* instead of just the summary.
*/
extern
void _dmalloc_chunk_log_changed(const unsigned long mark,
const int log_not_freed_b,
const int log_freed_b, const int details_b);
/*
* unsigned long _dmalloc_chunk_count_changed
*
* DESCRIPTION:
*
* Return the pointers that has changed since a pointer in time.
*
* RETURNS:
*
* Number of bytes changed since mark.
*
* ARGUMENTS:
*
* mark -> Dmalloc counter used to mark a specific time so that
* servers can check on the changed pointers.
*
* count_non_free_b -> If set to 1 then count the new not-freed
* (i.e. used) pointers.
*
* count_free_b -> If set to 1 then count the new freed pointers.
*/
extern
unsigned long _dmalloc_chunk_count_changed(const unsigned long mark,
const int count_not_freed_b,
const int count_freed_b);
/*
* void _dmalloc_chunk_get_stats
*
* DESCRIPTION:
*
* Return a number of statistics about the current heap.
*
* RETURNS:
*
* None.
*
* ARGUMENTS:
*
* heap_low_p <- Pointer to pointer which, if not 0L, will be set to
* the low address in the heap.
*
* heap_high_p <- Pointer to pointer which, if not 0L, will be set to
* the high address in the heap.
*
* total_space_p <- Pointer to an unsigned long which, if not 0L, will
* be set to the total space managed by the library including user
* space, administrative space, and overhead.
*
* user_space_p <- Pointer to an unsigned long which, if not 0L, will
* be set to the space given to the user process (allocated and free).
*
* current_allocated_p <- Pointer to an unsigned long which, if not
* 0L, will be set to the current allocated space given to the user
* process.
*
* current_pnt_np <- Pointer to an unsigned long which, if not 0L,
* will be set to the current number of pointers allocated by the user
* process.
*
* max_allocated_p <- Pointer to an unsigned long which, if not 0L,
* will be set to the maximum allocated space given to the user
* process.
*
* max_pnt_np <- Pointer to an unsigned long which, if not 0L, will be
* set to the maximum number of pointers allocated by the user
* process.
*
* max_one_p <- Pointer to an unsigned long which, if not 0L, will be
* set to the maximum allocated with 1 call by the user process.
*/
extern
void _dmalloc_chunk_get_stats(void **heap_low_p, void **heap_high_p,
unsigned long *total_space_p,
unsigned long *user_space_p,
unsigned long *current_allocated_p,
unsigned long *current_pnt_np,
unsigned long *max_allocated_p,
unsigned long *max_pnt_np,
unsigned long *max_one_p);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#endif /* ! __CHUNK_H__ */
|