CCCC - C and C++ Code Counter
9999-git
CCCC Development version (post-3.1.4)
Main Page
Classes
Files
File List
File Members
cccc
cccc_new.cc
Go to the documentation of this file.
1
/*
2
CCCC - C and C++ Code Counter
3
Copyright (C) 1994-2005 Tim Littlefair (tim_littlefair@hotmail.com)
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
// cccc_new.cc
20
21
// we are having some problems with heap corruption, so I am making sure that
22
// all class news and deletes are done by the malloc subsystem, and adding
23
// logging and deletion suppression
24
25
#include "
cccc.h
"
26
27
#include <stdlib.h>
28
#include <memory.h>
29
#ifdef CCCC_CONF_W32VC
30
#include <time.h>
31
#else
32
#ifdef CCCC_CONF_W32BC
33
#include <time.h>
34
#else
35
#include <sys/time.h>
36
#endif
37
#endif
38
39
#define USE_SYSTEM_NEW
40
#ifndef USE_SYSTEM_NEW
41
extern
int
dont_free
;
42
43
ofstream str(
"cccc_new.log"
);
44
45
void
*
46
operator
new
(
size_t
n)
47
{
48
void
*retval=malloc(n);
49
memset(retval,0xFA,n);
50
str << hex << retval <<
"@"
<< time(NULL) <<
"+"
<< n << endl;
51
return
retval;
52
}
53
54
void
*
55
operator
new
[](
size_t
n)
56
{
57
void
*retval=malloc(n);
58
memset(retval,0xFB,n);
59
str << hex << retval <<
"@"
<< time(NULL) <<
"*"
<< n << endl;
60
return
retval;
61
}
62
63
void
64
operator
delete
(
void
* cp)
65
{
66
str << hex << cp <<
"@"
<< time(NULL) <<
"-"
<< endl;
67
memset(cp,0xFC,1);
68
if
(
dont_free
==0)
69
{
70
free(cp);
71
}
72
}
73
74
void
75
operator
delete
[](
void
* cp)
76
{
77
str << hex << cp <<
"@"
<< time(NULL) <<
"/"
<< endl;
78
memset(cp,0xFD,1);
79
if
(
dont_free
==0)
80
{
81
free(cp);
82
}
83
}
84
85
86
#endif
87
88
89
90
91
dont_free
int dont_free
Definition:
ccccmain.cc:51
cccc.h
Generated on Sat Sep 19 2015 16:02:27 for CCCC - C and C++ Code Counter by
1.8.10