Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_devices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_devices
Commits
991e2a0d
Commit
991e2a0d
authored
9 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Fixing SE CLASS2 compilation
parent
5c270972
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Memleak_check.cpp
+1
-0
1 addition, 0 deletions
src/Memleak_check.cpp
src/Memleak_check.hpp
+47
-7
47 additions, 7 deletions
src/Memleak_check.hpp
src/memory/ExtPreAlloc.hpp
+29
-1
29 additions, 1 deletion
src/memory/ExtPreAlloc.hpp
src/ptr_info.hpp
+5
-4
5 additions, 4 deletions
src/ptr_info.hpp
with
82 additions
and
12 deletions
src/Memleak_check.cpp
+
1
−
0
View file @
991e2a0d
...
...
@@ -22,6 +22,7 @@ std::string col_stop("\e[0m");
// Print a message when allocation with id==msg_on_alloc is performed
long
int
msg_on_alloc
=
-
1
;
long
int
msg_on_dealloc
=
-
1
;
// throw when allocation with id==throw_on_alloc is performed
long
int
thr_on_alloc
=
-
1
;
This diff is collapsed.
Click to expand it.
src/Memleak_check.hpp
+
47
−
7
View file @
991e2a0d
...
...
@@ -32,6 +32,7 @@ typedef unsigned char * byte_ptr;
#define MEM_ERROR 1300lu
extern
long
int
msg_on_alloc
;
extern
long
int
msg_on_dealloc
;
extern
long
int
thr_on_alloc
;
extern
std
::
string
col_stop
;
extern
long
int
new_data
;
...
...
@@ -64,8 +65,11 @@ static bool remove_ptr(const void * ptr)
return
false
;
}
it
->
second
.
ref_id
--
;
// erase the pointer
active_ptr
.
erase
((
byte_ptr
)
ptr
);
if
(
it
->
second
.
ref_id
==
0
)
active_ptr
.
erase
((
byte_ptr
)
ptr
);
return
true
;
}
...
...
@@ -228,6 +232,16 @@ inline static void message_on_alloc(long int break_id)
msg_on_alloc
=
break_id
;
}
/* \brief When the de-allocation id==break_id is performed, print a message
*
* \param break_id
*
*/
inline
static
void
message_on_dealloc
(
long
int
break_id
)
{
msg_on_dealloc
=
break_id
;
}
/* \brief When the allocation id==break_id is performed, throw
*
* \param throw_id
...
...
@@ -251,14 +265,20 @@ inline static bool check_new(const void * data, size_t sz, size_t struct_id, siz
// Add a new pointer
new_data
++
;
ptr_info
&
ptr
=
active_ptr
[(
byte_ptr
)
data
];
ptr
.
size
=
sz
;
if
(
ptr
.
ref_id
>=
1
)
{
if
(
sz
>
ptr
.
size
)
ptr
.
size
=
sz
;
}
else
ptr
.
size
=
sz
;
ptr
.
id
=
new_data
;
ptr
.
struct_id
=
struct_id
;
ptr
.
project_id
=
project_id
;
ptr
.
ref_id
++
;
#ifdef SE_CLASS2_VERBOSE
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
std
::
cout
<<
"New data: "
<<
new_data
<<
" "
<<
data
<<
"
\n
"
;
std
::
cout
<<
"New data: "
<<
new_data
<<
" "
<<
data
<<
" "
<<
ptr
.
size
<<
"
\n
"
;
#endif
if
(
msg_on_alloc
==
new_data
)
...
...
@@ -283,6 +303,10 @@ inline static bool check_delete(const void * data)
if
(
data
==
NULL
)
return
true
;
// Delete the pointer
delete_data
++
;
if
(
msg_on_dealloc
==
(
long
int
)
delete_data
)
std
::
cout
<<
"Detected destruction: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" id="
<<
msg_on_alloc
<<
"
\n
"
;
bool
result
=
remove_ptr
(
data
);
#ifdef SE_CLASS2_VERBOSE
...
...
@@ -347,12 +371,28 @@ inline static bool check_valid(const void * ptr, size_t size_access)
if
(((
unsigned
char
*
)
l_b
->
first
)
+
sz
<
((
unsigned
char
*
)
ptr
)
+
size_access
)
{
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
bool
found
=
false
;
// Here we do a full search across all the registered pointers
std
::
map
<
byte_ptr
,
ptr_info
>::
iterator
fit
=
active_ptr
.
begin
();
for
(;
fit
!=
active_ptr
.
end
();
fit
++
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
" base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
if
(
ptr
>=
fit
->
first
&&
(((
unsigned
char
*
)
ptr
)
+
size_access
)
<=
(((
unsigned
char
*
)
fit
->
first
)
+
fit
->
second
.
size
)
)
{
found
=
true
;
break
;
}
}
if
(
found
==
false
)
{
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
"base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
}
}
return
false
;
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/memory/ExtPreAlloc.hpp
+
29
−
1
View file @
991e2a0d
...
...
@@ -48,6 +48,18 @@ public:
{
if
(
ref_cnt
!=
0
)
std
::
cerr
<<
"Error: "
<<
__FILE__
<<
" "
<<
__LINE__
<<
" destroying a live object"
<<
"
\n
"
;
#ifdef SE_CLASS2
// Eliminate all the old pointers
// Eliminate all the old pointers (only if has been used)
if
(
a_seq
!=
0
)
{
for
(
size_t
i
=
0
;
i
<
sequence
.
size
()
;
i
++
)
check_delete
(
getPointer
(
i
));
}
#endif
}
//! Default constructor
...
...
@@ -133,7 +145,6 @@ public:
*/
virtual
bool
allocate
(
size_t
sz
)
{
// Zero sized allocation are ignored
if
(
sz
==
0
)
return
true
;
...
...
@@ -150,6 +161,12 @@ public:
a_seq
++
;
#ifdef SE_CLASS2
check_new
(
getPointer
(),
sz
,
HEAPMEMORY_EVENT
,
0
);
#endif
return
true
;
}
...
...
@@ -239,6 +256,17 @@ public:
void
destroy
()
{
mem
->
destroy
();
#ifdef SE_CLASS2
// Eliminate all the old pointers (only if has been used)
if
(
a_seq
!=
0
)
{
for
(
size_t
i
=
0
;
i
<
sequence
.
size
()
;
i
++
)
check_delete
(
getPointer
(
i
));
}
#endif
}
/*! \brief Copy memory
...
...
This diff is collapsed.
Click to expand it.
src/ptr_info.hpp
+
5
−
4
View file @
991e2a0d
...
...
@@ -11,10 +11,11 @@
struct
ptr_info
{
size_t
id
;
size_t
struct_id
;
size_t
project_id
;
size_t
size
;
size_t
id
=
0
;
size_t
struct_id
=
0
;
size_t
project_id
=
0
;
size_t
size
=
0
;
size_t
ref_id
=
0
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment