Tracker: fix memory leak, CID 600996
We now only create the BString if we're going to put it in the list.
This commit is contained in:
parent
10489e89dd
commit
9b9c1e2779
@ -291,21 +291,19 @@ OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AddMimeTypeString(BObjectList<BString> &list, Model* model)
|
AddMimeTypeString(BObjectList<BString>& list, Model* model)
|
||||||
{
|
{
|
||||||
BString* mimeType = new BString(model->MimeType());
|
const char* modelMimeType = model->MimeType();
|
||||||
|
if (modelMimeType != NULL && *modelMimeType != '\0') {
|
||||||
if (mimeType->Length()) {
|
|
||||||
// only add the type if it's not already there
|
// only add the type if it's not already there
|
||||||
|
// ToDo: replace list with a hashmap
|
||||||
for (int32 i = list.CountItems(); i-- > 0;) {
|
for (int32 i = list.CountItems(); i-- > 0;) {
|
||||||
BString* string = list.ItemAt(i);
|
BString* string = list.ItemAt(i);
|
||||||
if (string != NULL && !string->ICompare(*mimeType)) {
|
if (string != NULL && string->ICompare(modelMimeType) == 0)
|
||||||
delete mimeType;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list.AddItem(mimeType);
|
list.AddItem(new BString(modelMimeType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user