AI 147028: Fix up aapt so it runs cleanly under the valgrind leak checker.

Automated import of CL 147028
This commit is contained in:
Marco Nelissen
2009-04-20 16:16:01 -07:00
committed by The Android Open Source Project
parent e38e90bf22
commit 6a1fadea85
4 changed files with 20 additions and 13 deletions

View File

@@ -125,7 +125,9 @@ public:
{
//printf("new AaptFile created %s\n", (const char*)sourceFile);
}
virtual ~AaptFile() { }
virtual ~AaptFile() {
free(mData);
}
const String8& getPath() const { return mPath; }
const AaptGroupEntry& getGroupEntry() const { return mGroupEntry; }
@@ -441,7 +443,13 @@ private:
AaptSymbolEntry mDefSymbol;
};
class ResourceTypeSet;
class ResourceTypeSet : public RefBase,
public KeyedVector<String8,sp<AaptGroup> >
{
public:
ResourceTypeSet();
};
/**
* Asset hierarchy being operated on.
@@ -449,8 +457,8 @@ class ResourceTypeSet;
class AaptAssets : public AaptDir
{
public:
AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false) { }
virtual ~AaptAssets() { }
AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false), mRes(NULL) { }
virtual ~AaptAssets() { delete mRes; }
const String8& getPackage() const { return mPackage; }
void setPackage(const String8& package) { mPackage = package; mSymbolsPrivatePackage = package; }
@@ -498,7 +506,7 @@ public:
inline KeyedVector<String8, sp<ResourceTypeSet> >* getResources() { return mRes; }
inline void
setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { mRes = res; }
setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { delete mRes; mRes = res; }
private:
String8 mPackage;

View File

@@ -44,6 +44,9 @@ struct image_info
}
free(allocRows);
}
free(info9Patch.xDivs);
free(info9Patch.yDivs);
free(info9Patch.colors);
}
png_uint_32 width;
@@ -833,6 +836,7 @@ static void write_png(const char* imageName,
int i;
png_unknown_chunk unknowns[1];
unknowns[0].data = NULL;
png_bytepp outRows = (png_bytepp) malloc((int) imageInfo.height * png_sizeof(png_bytep));
if (outRows == (png_bytepp) 0) {
@@ -939,6 +943,7 @@ static void write_png(const char* imageName,
free(outRows[i]);
}
free(outRows);
free(unknowns[0].data);
png_get_IHDR(write_ptr, write_info, &width, &height,
&bit_depth, &color_type, &interlace_type,

View File

@@ -45,13 +45,6 @@ static String8 parseResourceName(const String8& leaf)
}
}
class ResourceTypeSet : public RefBase,
public KeyedVector<String8,sp<AaptGroup> >
{
public:
ResourceTypeSet();
};
ResourceTypeSet::ResourceTypeSet()
:RefBase(),
KeyedVector<String8,sp<AaptGroup> >()
@@ -1055,6 +1048,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
printf(" Writing public definitions to %s.\n", bundle->getPublicOutputFile());
}
table.writePublicDefinitions(String16(assets->getPackage()), fp);
fclose(fp);
}
NOISY(
@@ -1072,7 +1066,6 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
return err;
}
}
return err;
}

View File

@@ -486,6 +486,7 @@ XMLNode::XMLNode(const String8& filename, const String16& s1, const String16& s2
XMLNode::XMLNode(const String8& filename)
: mFilename(filename)
{
memset(&mCharsValue, 0, sizeof(mCharsValue));
}
XMLNode::type XMLNode::getType() const