Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
e8316fd3
Commit
e8316fd3
authored
Sep 22, 2011
by
Davis King
Browse files
Changed shared_ptr slightly to avoid warnings from gcc.
parent
000b7e70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
dlib/smart_pointers/shared_ptr.h
dlib/smart_pointers/shared_ptr.h
+15
-9
No files found.
dlib/smart_pointers/shared_ptr.h
View file @
e8316fd3
...
@@ -116,6 +116,16 @@ namespace dlib
...
@@ -116,6 +116,16 @@ namespace dlib
}
}
};
};
struct
default_deleter
:
public
shared_ptr_deleter
{
void
del
(
const
void
*
p
)
{
delete
((
T
*
)
p
);
}
void
*
get_deleter_void
(
const
std
::
type_info
&
)
const
{
return
0
;
}
};
public:
public:
typedef
T
element_type
;
typedef
T
element_type
;
...
@@ -136,6 +146,7 @@ namespace dlib
...
@@ -136,6 +146,7 @@ namespace dlib
try
try
{
{
shared_node
=
new
shared_ptr_node
;
shared_node
=
new
shared_ptr_node
;
shared_node
->
del
=
new
default_deleter
;
}
}
catch
(...)
catch
(...)
{
{
...
@@ -177,15 +188,8 @@ namespace dlib
...
@@ -177,15 +188,8 @@ namespace dlib
if
(
shared_node
->
ref_count
==
1
)
if
(
shared_node
->
ref_count
==
1
)
{
{
// delete the data in the appropriate way
// delete the data in the appropriate way
if
(
shared_node
->
del
)
shared_node
->
del
->
del
(
data
);
{
delete
shared_node
->
del
;
shared_node
->
del
->
del
(
data
);
delete
shared_node
->
del
;
}
else
{
delete
data
;
}
// notify any weak_ptrs that the data has now expired
// notify any weak_ptrs that the data has now expired
if
(
shared_node
->
weak_node
)
if
(
shared_node
->
weak_node
)
...
@@ -301,6 +305,7 @@ namespace dlib
...
@@ -301,6 +305,7 @@ namespace dlib
<<
"
\n\t
this: "
<<
this
<<
"
\n\t
this: "
<<
this
);
);
shared_node
=
new
shared_ptr_node
;
shared_node
=
new
shared_ptr_node
;
shared_node
->
del
=
new
default_deleter
;
data
=
r
.
release
();
data
=
r
.
release
();
}
}
...
@@ -334,6 +339,7 @@ namespace dlib
...
@@ -334,6 +339,7 @@ namespace dlib
reset
();
reset
();
shared_node
=
new
shared_ptr_node
;
shared_node
=
new
shared_ptr_node
;
shared_node
->
del
=
new
default_deleter
;
data
=
r
.
release
();
data
=
r
.
release
();
return
*
this
;
return
*
this
;
}
}
...
...
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