Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
eloadas_peldak
/
ea_08
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
982bdb7f
authored
Apr 11, 2022
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
új memtrace
parent
d1f5956e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
19 deletions
+49
-19
SharksAndFishes/SharksAndFishes.cbp
+1
-5
SharksAndFishes/memtrace.cpp
+24
-10
SharksAndFishes/memtrace.h
+24
-4
No files found.
SharksAndFishes/SharksAndFishes.cbp
View file @
982bdb7f
...
...
@@ -44,10 +44,6 @@
<Unit
filename=
"obj.h"
/>
<Unit
filename=
"ocean.cpp"
/>
<Unit
filename=
"ocean.h"
/>
<Extensions>
<code_completion
/>
<envvars
/>
<debugger
/>
</Extensions>
<Extensions
/>
</Project>
</CodeBlocks_project_file>
SharksAndFishes/memtrace.cpp
View file @
982bdb7f
...
...
@@ -5,8 +5,9 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
meset felszabaditaskor: 2018.
me
m
set felszabaditaskor: 2018.
typo: 2019.
poi_check: 2021.
*********************************/
/*definialni kell, ha nem paracssorbol allitjuk be (-DMEMTRACE) */
...
...
@@ -178,7 +179,6 @@ START_NAMESPACE
dying
=
TRUE
;
exit
(
120
);
}
static
void
initialize
();
END_NAMESPACE
...
...
@@ -188,6 +188,7 @@ END_NAMESPACE
#ifdef MEMTRACE_TO_MEMORY
START_NAMESPACE
typedef
struct
_registry_item
{
void
*
p
;
/* mem pointer*/
size_t
size
;
/* size*/
...
...
@@ -197,6 +198,12 @@ START_NAMESPACE
static
registry_item
registry
;
/*sentinel*/
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
static
void
print_registry_item
(
registry_item
*
p
)
{
if
(
p
)
{
print_registry_item
(
p
->
next
);
...
...
@@ -225,6 +232,13 @@ START_NAMESPACE
}
return
0
;
}
/* Ellenorzi, hogy a pointer regisztralt-e. Ha nem, akkor 0-val tér vissza */
int
poi_check
(
void
*
pu
)
{
if
(
pu
==
NULL
)
return
1
;
initialize
();
return
find_registry_item
(
P
(
pu
))
->
next
!=
NULL
;
}
END_NAMESPACE
#endif
/*MEMTRACE_TO_MEMORY*/
...
...
@@ -271,14 +285,6 @@ START_NAMESPACE
return
TRUE
;
}
#ifdef MEMTRACE_TO_MEMORY
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
#endif
static
void
unregister_memory
(
void
*
p
,
call_t
call
)
{
initialize
();
#ifdef MEMTRACE_TO_FILE
...
...
@@ -487,7 +493,15 @@ void operator delete(void * p) THROW_NOTHING {
void
operator
delete
[](
void
*
p
)
THROW_NOTHING
{
memtrace
::
traced_delete
(
p
,
FDELETEARR
);
}
#if __cplusplus >= 201402L
void
operator
delete
(
void
*
p
,
size_t
)
THROW_NOTHING
{
memtrace
::
traced_delete
(
p
,
FDELETE
);
}
void
operator
delete
[](
void
*
p
,
size_t
)
THROW_NOTHING
{
memtrace
::
traced_delete
(
p
,
FDELETEARR
);
}
#endif
/* Visual C++ 2012 miatt kell, mert háklis, hogy nincs megfelelő delete, bár senki sem használja */
void
operator
delete
(
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
{
...
...
SharksAndFishes/memtrace.h
View file @
982bdb7f
...
...
@@ -5,7 +5,7 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.,
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
inclue-ok: 2017., 2018.
2019
.
inclue-ok: 2017., 2018.
, 2019., 2021
.
*********************************/
#ifndef MEMTRACE_H
...
...
@@ -102,6 +102,7 @@ END_NAMESPACE
#if defined(MEMTRACE_TO_MEMORY)
START_NAMESPACE
int
mem_check
(
void
);
int
poi_check
(
void
*
);
END_NAMESPACE
#endif
...
...
@@ -153,6 +154,17 @@ END_NAMESPACE
#include <map>
#include <algorithm>
#include <functional>
#include <memory>
#include <iomanip>
#include <locale>
#include <typeinfo>
#include <ostream>
#include <stdexcept>
#include <ctime>
#if __cplusplus >= 201103L
#include <iterator>
#include <regex>
#endif
#endif
#ifdef MEMTRACE_CPP
namespace
std
{
...
...
@@ -178,8 +190,7 @@ START_NAMESPACE
#define realloc(old,size) TRACEC(traced_realloc)(old,size,#size,__LINE__,__FILE__)
void
*
traced_realloc
(
void
*
old
,
size_t
size
,
const
char
*
size_txt
,
int
line
,
const
char
*
file
);
void
mem_dump
(
void
const
*
mem
,
size_t
size
,
FILE
*
fp
);
void
mem_dump
(
void
const
*
mem
,
size_t
size
,
FILE
*
fp
=
stdout
);
END_NAMESPACE
#endif
/*MEMTRACE_C*/
...
...
@@ -200,6 +211,12 @@ void * operator new[](size_t size) THROW_BADALLOC;
void
operator
delete
(
void
*
p
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
)
THROW_NOTHING
;
#if __cplusplus >= 201402L
// sized delete miatt: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3536.html
void
operator
delete
(
void
*
p
,
size_t
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
,
size_t
)
THROW_NOTHING
;
#endif
/* Visual C++ 2012 miatt kell, mert háklis, hogy nincs megfelelő delete, bár senki sem használja */
void
operator
delete
(
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
...
...
@@ -215,5 +232,8 @@ void operator delete[](void *p, int, const char *) THROW_NOTHING;
#endif
/*MEMTRACE_CPP*/
#endif
/*FROM_MEMTRACE_CPP*/
#endif
/*MEMCHECK*/
#else
#pragma message ( "MEMTRACE NOT DEFINED" )
#endif
/*MEMTRACE*/
#endif
/*MEMTRACE_H*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment