Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
savoirfairelinux
jami-daemon
Commits
56024357
Commit
56024357
authored
13 years ago
by
Rafaël Carré
Browse files
Options
Downloads
Patches
Plain Diff
* #6392: fix memory leak in history
parent
3518de4a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/history/historymanager.cpp
+22
-27
22 additions, 27 deletions
sflphone-common/src/history/historymanager.cpp
with
22 additions
and
27 deletions
sflphone-common/src/history/historymanager.cpp
+
22
−
27
View file @
56024357
...
...
@@ -35,27 +35,26 @@
#include
<cc++/file.h>
#include
<time.h>
namespace
{
static
void
free_history
(
HistoryItemMap
&
history_items
)
{
HistoryItemMap
::
iterator
iter
;
for
(
iter
=
history_items
.
begin
();
iter
!=
history_items
.
end
();
++
iter
)
delete
*
iter
;
history_items
.
clear
();
}
}
// end anonymous namespace
HistoryManager
::
HistoryManager
()
:
_history_loaded
(
false
),
_history_path
(
""
)
{
}
HistoryManager
::~
HistoryManager
()
{
HistoryItemMap
::
iterator
iter
=
_history_items
.
begin
();
HistoryItem
*
item
;
while
(
iter
!=
_history_items
.
end
())
{
item
=
*
iter
;
delete
item
;
iter
++
;
}
// Clear the history map
_history_items
.
clear
();
free_history
(
_history_items
);
}
int
HistoryManager
::
load_history
(
int
limit
,
std
::
string
path
)
...
...
@@ -277,15 +276,14 @@ int HistoryManager::set_serialized_history (std::vector<std::string> history, in
_debug
(
"HistoryManager: Set serialized history"
);
// Clear the existing history
_history_items
.
clear
(
);
free_history
(
_history_items
);
// We want to save only the items recent enough (ie compared to CONFIG_HISTORY_LIMIT)
// Get the current timestamp
(
void
)
time
(
&
current_timestamp
);
history_limit
=
get_unix_timestamp_equivalent
(
limit
);
iter
=
history
.
begin
();
while
(
iter
!=
history
.
end
())
{
for
(
iter
=
history
.
begin
()
;
iter
!=
history
.
end
()
;
iter
++
)
{
new_item
=
new
HistoryItem
(
*
iter
);
if
(
new_item
==
NULL
)
{
_error
(
"HistoryManager: Error: Could not create history item"
);
...
...
@@ -294,12 +292,9 @@ int HistoryManager::set_serialized_history (std::vector<std::string> history, in
if
(
item_timestamp
>=
(
(
int
)
current_timestamp
-
history_limit
))
{
add_new_history_entry
(
new_item
);
items_added
++
;
}
else
{
}
else
{
delete
new_item
;
}
iter
++
;
}
return
items_added
;
...
...
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