Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Core Modules
dune-common
Commits
3a2dd682
Commit
3a2dd682
authored
12 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Removed unnecessary memory allocations from shared_ptr together with some memory leaks.
[[Imported from SVN: r7053]]
parent
311e43d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/shared_ptr.hh
+24
-8
24 additions, 8 deletions
dune/common/shared_ptr.hh
with
24 additions
and
8 deletions
dune/common/shared_ptr.hh
+
24
−
8
View file @
3a2dd682
...
...
@@ -129,6 +129,9 @@ namespace Dune
template
<
class
T1
>
inline
shared_ptr
&
operator
=
(
const
shared_ptr
<
T1
>&
pointer
);
/** \brief Assignment operator */
inline
shared_ptr
&
operator
=
(
const
shared_ptr
&
pointer
);
/** \brief Dereference as object */
inline
element_type
&
operator
*
();
...
...
@@ -148,7 +151,7 @@ namespace Dune
/** \brief Checks if shared_ptr manages an object, i.e. whether get() != 0. */
operator
bool
()
const
{
return
count_
->
count_
!=
0
&&
rep_
!=
nullptr
;
return
count_
!=
0
&&
rep_
!=
0
;
}
/** \brief Swap content of this shared_ptr and another */
...
...
@@ -171,7 +174,9 @@ namespace Dune
int
use_count
()
const
;
private
:
/** \brief Assignment operator */
template
<
class
T1
>
inline
shared_ptr
&
assign
(
const
shared_ptr
<
T1
>&
pointer
);
/** @brief Adds call to deleter to SharedCount. */
template
<
class
Deleter
>
class
SharedCountImpl
:
...
...
@@ -232,8 +237,7 @@ namespace Dune
inline
shared_ptr
<
T
>::
shared_ptr
(
nullptr_t
n
)
{
rep_
=
0
;
count_
=
new
SharedCountImpl
<
DefaultDeleter
>
(
rep_
,
DefaultDeleter
());
count_
->
count_
=
0
;
count_
=
0
;
}
template
<
class
T
>
...
...
@@ -248,8 +252,7 @@ namespace Dune
inline
shared_ptr
<
T
>::
shared_ptr
()
{
rep_
=
0
;
count_
=
new
SharedCountImpl
<
DefaultDeleter
>
(
rep_
,
DefaultDeleter
());
count_
->
count_
=
0
;
count_
=
0
;
}
template
<
class
T
>
...
...
@@ -272,6 +275,19 @@ namespace Dune
template
<
class
T
>
template
<
class
T1
>
inline
shared_ptr
<
T
>&
shared_ptr
<
T
>::
operator
=
(
const
shared_ptr
<
T1
>&
other
)
{
return
assign
(
other
);
}
template
<
class
T
>
inline
shared_ptr
<
T
>&
shared_ptr
<
T
>::
operator
=
(
const
shared_ptr
&
other
)
{
return
assign
(
other
);
}
template
<
class
T
>
template
<
class
T1
>
inline
shared_ptr
<
T
>&
shared_ptr
<
T
>::
assign
(
const
shared_ptr
<
T1
>&
other
)
{
if
(
other
.
count_
)
(
other
.
count_
->
count_
)
++
;
...
...
@@ -288,9 +304,9 @@ namespace Dune
template
<
class
T
>
inline
shared_ptr
<
T
>::~
shared_ptr
()
{
if
(
rep_
!=
nullptr
&&
--
(
count_
->
count_
)
==
0
)
{
if
(
rep_
!=
0
&&
--
(
count_
->
count_
)
==
0
)
{
delete
count_
;
rep_
=
nullptr
;
rep_
=
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