Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
06779d24
There was a problem fetching the pipeline summary.
Commit
06779d24
authored
6 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
fix memory leak in ptr vector and array
parent
a81755d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2std/src/extensions/ptr_array.hpp
+3
-5
3 additions, 5 deletions
alib2std/src/extensions/ptr_array.hpp
alib2std/src/extensions/ptr_vector.hpp
+4
-6
4 additions, 6 deletions
alib2std/src/extensions/ptr_vector.hpp
with
7 additions
and
11 deletions
alib2std/src/extensions/ptr_array.hpp
+
3
−
5
View file @
06779d24
...
@@ -207,20 +207,18 @@ public:
...
@@ -207,20 +207,18 @@ public:
template
<
class
R
>
template
<
class
R
>
iterator
set
(
const_iterator
pos
,
R
&&
value
)
{
iterator
set
(
const_iterator
pos
,
R
&&
value
)
{
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
ext
::
clone
(
std
::
forward
<
R
>
(
value
)
);
return
set
(
pos
,
ext
::
clone
(
std
::
forward
<
R
>
(
value
)
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
template
<
class
R
>
iterator
set
(
const_iterator
pos
,
T
*
value
)
{
iterator
set
(
const_iterator
pos
,
T
*
value
)
{
delete
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
);
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
value
;
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
value
;
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
template
<
class
R
,
class
...
Args
>
template
<
class
R
,
class
...
Args
>
iterator
emplace_set
(
const_iterator
pos
,
Args
&&
...
args
)
{
iterator
emplace_set
(
const_iterator
pos
,
Args
&&
...
args
)
{
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
new
R
(
std
::
forward
<
Args
>
(
args
)
...
)
;
return
set
(
pos
,
new
R
(
std
::
forward
<
Args
>
(
args
)
...
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
void
swap
(
ptr_array
&
other
)
{
void
swap
(
ptr_array
&
other
)
{
...
...
This diff is collapsed.
Click to expand it.
alib2std/src/extensions/ptr_vector.hpp
+
4
−
6
View file @
06779d24
...
@@ -236,20 +236,18 @@ public:
...
@@ -236,20 +236,18 @@ public:
template
<
class
R
>
template
<
class
R
>
iterator
set
(
const_iterator
pos
,
R
&&
value
)
{
iterator
set
(
const_iterator
pos
,
R
&&
value
)
{
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
ext
::
clone
(
std
::
forward
<
R
>
(
value
)
);
return
set
(
pos
,
ext
::
clone
(
std
::
forward
<
R
>
(
value
)
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
template
<
class
R
>
iterator
set
(
const_iterator
pos
,
T
*
value
)
{
iterator
set
(
const_iterator
pos
,
T
*
value
)
{
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
value
;
delete
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
);
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
value
;
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
template
<
class
R
,
class
...
Args
>
template
<
class
R
,
class
...
Args
>
iterator
emplace_set
(
const_iterator
pos
,
Args
&&
...
args
)
{
iterator
emplace_set
(
const_iterator
pos
,
Args
&&
...
args
)
{
m_data
.
at
(
std
::
distance
(
cbegin
(
),
pos
)
)
=
new
R
(
std
::
forward
<
Args
>
(
args
)
...
)
;
return
set
(
pos
,
new
R
(
std
::
forward
<
R
>
(
args
)
...
)
);
return
dereferencer
(
m_data
.
begin
(
)
+
std
::
distance
(
cbegin
(
),
pos
)
);
}
}
template
<
class
R
>
template
<
class
R
>
...
...
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