]> git.pld-linux.org Git - packages/squid.git/blame - squid-3.0.PRE3-cbdatadebugleak.patch
c4ae820794f301b909415e0f4728f1c9 squid-2.5.STABLE9-ftp_EPLF.patch
[packages/squid.git] / squid-3.0.PRE3-cbdatadebugleak.patch
CommitLineData
36aa8c36
JR
1Index: squid3/src/cbdata.cc
2diff -c squid3/src/cbdata.cc:1.59 squid3/src/cbdata.cc:1.60
3*** squid3/src/cbdata.cc:1.59 Wed Jul 16 01:18:16 2003
4--- squid3/src/cbdata.cc Mon Sep 1 17:41:17 2003
5***************
6*** 83,92 ****
7 void dump(StoreEntry *)const;
8 #endif
9
10! void deleteSelf();
11 int valid;
12 int locks;
13! int type;
14 #if CBDATA_DEBUG
15
16 void addHistory(char const *label, char const *file, int line)
17--- 83,95 ----
18 void dump(StoreEntry *)const;
19 #endif
20
21! void *operator new(size_t size, void *where);
22! void operator delete(void *where, void *where);
23!
24! ~cbdata();
25 int valid;
26 int locks;
27! cbdata_type type;
28 #if CBDATA_DEBUG
29
30 void addHistory(char const *label, char const *file, int line)
31***************
32*** 106,111 ****
33--- 109,116 ----
34 /* cookie used while debugging */
35 long cookie;
36 /* MUST be the last per-instance member */
37+ /* TODO: examine making cbdata templated on this - so we get type
38+ * safe access to data - RBC 20030902 */
39 void *data;
40 void check() const { assert(cookie == ((long)this ^ Cookie));}
41
42***************
43*** 119,124 ****
44--- 124,145 ----
45 const long cbdata::Cookie((long)0xDEADBEEF);
46 const long cbdata::Offset(MakeOffset());
47
48+ void *
49+ cbdata::operator new(size_t size, void *where)
50+ {
51+ // assert (size == sizeof(cbdata));
52+ return where;
53+ }
54+
55+ void
56+ cbdata::operator delete(void *where, void *where2)
57+ {
58+ /* Only ever invoked when placement new throws
59+ * an exception. Used to prevent an incorrect
60+ * free.
61+ */
62+ }
63+
64 long
65 cbdata::MakeOffset()
66 {
67***************
68*** 141,148 ****
69 *cbdata_index = NULL;
70 int cbdata_types = 0;
71
72! void
73! cbdata::deleteSelf()
74 {
75 #if CBDATA_DEBUG
76 CBDataCall *aCall;
77--- 162,168 ----
78 *cbdata_index = NULL;
79 int cbdata_types = 0;
80
81! cbdata::~cbdata()
82 {
83 #if CBDATA_DEBUG
84 CBDataCall *aCall;
85***************
86*** 156,163 ****
87
88 if (free_func)
89 free_func(&data);
90-
91- memPoolFree(cbdata_index[type].pool, this);
92 }
93
94 static void
95--- 176,181 ----
96***************
97*** 240,246 ****
98 {
99 cbdata *p;
100 assert(type > 0 && type < cbdata_types);
101! p = (cbdata *)memPoolAlloc(cbdata_index[type].pool);
102 p->type = type;
103 p->valid = 1;
104 p->locks = 0;
105--- 258,266 ----
106 {
107 cbdata *p;
108 assert(type > 0 && type < cbdata_types);
109! p = new (memPoolAlloc(cbdata_index[type].pool)) cbdata;
110! // p = (cbdata *)memPoolAlloc(cbdata_index[type].pool);
111!
112 p->type = type;
113 p->valid = 1;
114 p->locks = 0;
115***************
116*** 297,303 ****
117 dlinkDelete(&c->link, &cbdataEntries);
118 #endif
119
120! c->deleteSelf();
121 return NULL;
122 }
123
124--- 317,336 ----
125 dlinkDelete(&c->link, &cbdataEntries);
126 #endif
127
128! cbdata_type theType = c->type;
129! c->cbdata::~cbdata();
130!
131! /* This is ugly. But: operator delete doesn't get
132! * the type parameter, so we can't use that
133! * to free the memory.
134! * So, we free it ourselves.
135! * Note that this means a non-placement
136! * new would be a seriously bad idea.
137! * Lastly, if we where a templated class,
138! * we could use the normal delete operator
139! * and it would Just Work. RBC 20030902
140! */
141! memPoolFree(cbdata_index[theType].pool, c);
142 return NULL;
143 }
144
145***************
146*** 381,387 ****
147
148 #endif
149
150! c->deleteSelf();
151 }
152
153 int
154--- 414,434 ----
155
156 #endif
157
158! cbdata_type theType = c->type;
159!
160! c->cbdata::~cbdata();
161!
162! /* This is ugly. But: operator delete doesn't get
163! * the type parameter, so we can't use that
164! * to free the memory.
165! * So, we free it ourselves.
166! * Note that this means a non-placement
167! * new would be a seriously bad idea.
168! * Lastly, if we where a templated class,
169! * we could use the normal delete operator
170! * and it would Just Work. RBC 20030902
171! */
172! memPoolFree(cbdata_index[theType].pool, c);
173 }
174
175 int
This page took 0.106343 seconds and 4 git commands to generate.