Skip to content

Commit

Permalink
logd: white and black switch to std::list
Browse files Browse the repository at this point in the history
(cherry pick from commit e0ed16c)

Bug: 23350706
Change-Id: I981d9fa63a0d87eb309485cca93cfc44fc0506cc
  • Loading branch information
Mark Salyzyn committed Aug 20, 2015
1 parent a68a516 commit dc1c936
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
28 changes: 11 additions & 17 deletions logd/LogWhiteBlackList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ void Prune::format(char **strp) {
}

PruneList::PruneList() : mWorstUidEnabled(true) {
mNaughty.clear();
mNice.clear();
}

PruneList::~PruneList() {
PruneCollection::iterator it;
for (it = mNice.begin(); it != mNice.end();) {
delete (*it);
it = mNice.erase(it);
}
for (it = mNaughty.begin(); it != mNaughty.end();) {
delete (*it);
it = mNaughty.erase(it);
}
}
Expand All @@ -70,11 +66,9 @@ int PruneList::init(char *str) {
mWorstUidEnabled = true;
PruneCollection::iterator it;
for (it = mNice.begin(); it != mNice.end();) {
delete (*it);
it = mNice.erase(it);
}
for (it = mNaughty.begin(); it != mNaughty.end();) {
delete (*it);
it = mNaughty.erase(it);
}

Expand Down Expand Up @@ -142,28 +136,28 @@ int PruneList::init(char *str) {
// insert sequentially into list
PruneCollection::iterator it = list->begin();
while (it != list->end()) {
Prune *p = *it;
int m = uid - p->mUid;
Prune &p = *it;
int m = uid - p.mUid;
if (m == 0) {
if (p->mPid == p->pid_all) {
if (p.mPid == p.pid_all) {
break;
}
if ((pid == p->pid_all) && (p->mPid != p->pid_all)) {
if ((pid == p.pid_all) && (p.mPid != p.pid_all)) {
it = list->erase(it);
continue;
}
m = pid - p->mPid;
m = pid - p.mPid;
}
if (m <= 0) {
if (m < 0) {
list->insert(it, new Prune(uid,pid));
list->insert(it, Prune(uid,pid));
}
break;
}
++it;
}
if (it == list->end()) {
list->push_back(new Prune(uid,pid));
list->push_back(Prune(uid,pid));
}
if (!*str) {
break;
Expand Down Expand Up @@ -193,7 +187,7 @@ void PruneList::format(char **strp) {

for (it = mNice.begin(); it != mNice.end(); ++it) {
char *a = NULL;
(*it)->format(&a);
(*it).format(&a);

string.appendFormat(fmt, a);
fmt = nice_format;
Expand All @@ -205,7 +199,7 @@ void PruneList::format(char **strp) {
fmt = naughty_format + (*fmt != ' ');
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
char *a = NULL;
(*it)->format(&a);
(*it).format(&a);

string.appendFormat(fmt, a);
fmt = naughty_format;
Expand All @@ -223,7 +217,7 @@ void PruneList::format(char **strp) {
bool PruneList::naughty(LogBufferElement *element) {
PruneCollection::iterator it;
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
if (!(*it)->cmp(element)) {
if (!(*it).cmp(element)) {
return true;
}
}
Expand All @@ -233,7 +227,7 @@ bool PruneList::naughty(LogBufferElement *element) {
bool PruneList::nice(LogBufferElement *element) {
PruneCollection::iterator it;
for (it = mNice.begin(); it != mNice.end(); ++it) {
if (!(*it)->cmp(element)) {
if (!(*it).cmp(element)) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions logd/LogWhiteBlackList.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <sys/types.h>

#include <utils/List.h>
#include <list>

#include <LogBufferElement.h>

Expand Down Expand Up @@ -47,7 +47,7 @@ class Prune {
void format(char **strp);
};

typedef android::List<Prune *> PruneCollection;
typedef std::list<Prune> PruneCollection;

class PruneList {
PruneCollection mNaughty;
Expand Down

0 comments on commit dc1c936

Please sign in to comment.