source: trunk/include/helpers/memdebug.h@ 7

Last change on this file since 7 was 7, checked in by umoeller, 25 years ago

Initial checkin of helpers code, which used to be in WarpIN.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1
2/*
3 *@@sourcefile memdebug.h:
4 * header file for memdebug.c.
5 * See remarks there.
6 *
7 * Note: Version numbering in this file relates to XWorkplace version
8 * numbering.
9 *
10 *@@include #include <os2.h>
11 *@@include #include "memdebug.h"
12 */
13
14/* Copyright (C) 2000 Ulrich M”ller.
15 * This file is part of the XWorkplace source package.
16 * XWorkplace is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published
18 * by the Free Software Foundation, in version 2 as it comes in the
19 * "COPYING" file of the XWorkplace main distribution.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 */
25
26#if __cplusplus
27extern "C" {
28#endif
29
30#ifndef MEMDEBUG_HEADER_INCLUDED
31 #define MEMDEBUG_HEADER_INCLUDED
32
33 #ifndef __stdlib_h // <stdlib.h>
34 #error stdlib.h must be included before memdebug.h.
35 #endif
36
37 typedef void (FNCBMEMDLOG)(const char*); // message
38 typedef FNCBMEMDLOG *PFNCBMEMDLOG;
39
40 // global variable for memory error logger func
41 extern PFNCBMEMDLOG G_pMemdLogFunc;
42
43 void* memdMalloc(size_t stSize,
44 const char *pcszSourceFile,
45 unsigned long ulLine,
46 const char *pcszFunction);
47
48 void* memdCalloc(size_t num,
49 size_t stSize,
50 const char *pcszSourceFile,
51 unsigned long ulLine,
52 const char *pcszFunction);
53
54 void memdFree(void *p,
55 const char *pcszSourceFile,
56 unsigned long ulLine,
57 const char *pcszFunction);
58
59 unsigned long memdReleaseFreed(void);
60
61 #ifdef __XWPMEMDEBUG__
62
63 #ifndef DONT_REPLACE_MALLOC
64 #define malloc(ul) memdMalloc(ul, __FILE__, __LINE__, __FUNCTION__)
65 #define calloc(n, size) memdCalloc(n, size, __FILE__, __LINE__, __FUNCTION__)
66 #define free(p) memdFree(p, __FILE__, __LINE__, __FUNCTION__)
67
68 #ifdef __string_h
69 // string.h included and debugging is on:
70 // redefine strdup to use memory debugging
71 #define strdup(psz) \
72 strcpy( (char*)memdMalloc(strlen(psz) + 1, __FILE__, __LINE__, __FUNCTION__), psz)
73 // the original crashes also if psz is NULL
74 #endif
75
76 #endif
77 #endif
78
79 #ifdef PM_INCLUDED
80 /********************************************************************
81 * *
82 * XFolder debugging helpers *
83 * *
84 ********************************************************************/
85
86 #ifdef _PMPRINTF_
87 void memdDumpMemoryBlock(PBYTE pb,
88 ULONG ulSize,
89 ULONG ulIndent);
90 #else
91 // _PMPRINTF not #define'd: do nothing
92 #define memdDumpMemoryBlock(pb, ulSize, ulIndent)
93 #endif
94
95 /* ******************************************************************
96 * *
97 * Heap debugging window *
98 * *
99 ********************************************************************/
100
101 MRESULT EXPENTRY memd_fnwpMemDebug(HWND hwndClient, ULONG msg, MPARAM mp1, MPARAM mp2);
102
103 VOID memdCreateMemDebugWindow(VOID);
104 #endif
105
106#endif
107
108#if __cplusplus
109}
110#endif
111
Note: See TracBrowser for help on using the repository browser.