aug_alloc.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Id$
  3. *
  4. * POSTGRES module, portions of this code were templated using
  5. * the mysql module, thus it's similarity.
  6. *
  7. *
  8. * Copyright (C) 2003 August.Net Services, LLC
  9. *
  10. * This file is part of ser, a free SIP server.
  11. *
  12. * ser is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version
  16. *
  17. * For a license to use the ser software under conditions
  18. * other than those described here, or to purchase support for this
  19. * software, please contact iptel.org by e-mail at the following addresses:
  20. * [email protected]
  21. *
  22. * ser is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  30. *
  31. * ---
  32. *
  33. * History
  34. * -------
  35. * 2003-04-06 initial code written (Greg Fausak/Andy Fullford)
  36. *
  37. */
  38. /*
  39. ** ________________________________________________________________________
  40. **
  41. **
  42. ** $RCSfile$
  43. ** $Revision$
  44. **
  45. ** Last change $Date$
  46. ** Last change $Author$
  47. ** $State$
  48. ** $Locker$
  49. **
  50. ** Original author: Andrew Fullford
  51. **
  52. ** Copyright (C) August Associates 1995
  53. **
  54. ** ________________________________________________________________________
  55. */
  56. /* AM_TYPE: (INSTALL_INC) */
  57. #ifndef AUG_ALLOC_H
  58. #define AUG_ALLOC_H
  59. #include <stdlib.h>
  60. typedef struct
  61. {
  62. int estimated_overhead_per_alloc; /* assumes malloc overhead
  63. is 8 bytes. This is
  64. probably low */
  65. unsigned long alloc_ops; /* Total allocs since epoch */
  66. unsigned long free_ops; /* Total frees since epoch */
  67. unsigned long realloc_ops; /* Total reallocs since epoch */
  68. unsigned long current_bytes_allocated; /* Running allocation total */
  69. } augAllocStats;
  70. #define aug_alloc(s,p) aug_alloc_loc((s),(p),augDAB__FILE__,augDAB__LINE__)
  71. #define aug_realloc(s,m) aug_realloc_loc((s),(m),augDAB__FILE__,augDAB__LINE__)
  72. #define aug_strdup(s,p) aug_strdup_loc((s),(p),augDAB__FILE__,augDAB__LINE__)
  73. #define aug_vecdup(v,p) aug_vecdup_loc((v),(p),augDAB__FILE__,augDAB__LINE__)
  74. #define aug_free(m) aug_free_loc((m),augDAB__FILE__,augDAB__LINE__)
  75. #define aug_foster(m,p) aug_foster_loc((m),(p),augDAB__FILE__,augDAB__LINE__)
  76. typedef void augNoMemFunc(size_t size, char *func, char *file, int line);
  77. extern augNoMemFunc *aug_set_nomem_func(augNoMemFunc *new_func);
  78. extern void *aug_alloc_loc(size_t size, void *parent, char *file, int line);
  79. extern void *aug_realloc_loc(size_t size, void *prev, char *file, int line);
  80. extern char *aug_strdup_loc(char *str, void *parent, char *file, int line);
  81. extern char **aug_vecdup_loc(char **vec, void *parent, char *file, int line);
  82. extern void aug_free_loc(void *mem, char *file, int line);
  83. extern void aug_foster_loc(void *mem, void *new_parent, char *file, int line);
  84. extern augAllocStats *aug_alloc_stats(void);
  85. #endif /* AUG_ALLOC_H */