summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm48
1 files changed, 21 insertions, 27 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 0625b35..1968599 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -83,8 +83,6 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apr-1/apr_pools.h>
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
@@ -580,14 +578,14 @@ class CYString {
cache_ = reinterpret_cast<CFStringRef>(CFRetain(rhs.cache_));
}
- void copy(apr_pool_t *pool) {
- char *temp(reinterpret_cast<char *>(apr_palloc(pool, size_ + 1)));
+ void copy(CYPool *pool) {
+ char *temp(pool->malloc<char>(size_ + 1));
memcpy(temp, data_, size_);
temp[size_] = '\0';
data_ = temp;
}
- void set(apr_pool_t *pool, const char *data, size_t size) {
+ void set(CYPool *pool, const char *data, size_t size) {
if (size == 0)
clear();
else {
@@ -601,11 +599,11 @@ class CYString {
}
}
- _finline void set(apr_pool_t *pool, const char *data) {
+ _finline void set(CYPool *pool, const char *data) {
set(pool, data, data == NULL ? 0 : strlen(data));
}
- _finline void set(apr_pool_t *pool, const std::string &rhs) {
+ _finline void set(CYPool *pool, const std::string &rhs) {
set(pool, rhs.data(), rhs.size());
}
@@ -1118,7 +1116,7 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
@interface Database : NSObject {
NSZone *zone_;
- apr_pool_t *pool_;
+ CYPool pool_;
unsigned era_;
@@ -1556,7 +1554,7 @@ static void PackageImport(const void *key, const void *value, void *context) {
_transient NSObject<SourceDelegate> *delegate_;
}
-- (Source *) initWithMetaIndex:(metaIndex *)index forDatabase:(Database *)database inPool:(apr_pool_t *)pool;
+- (Source *) initWithMetaIndex:(metaIndex *)index forDatabase:(Database *)database inPool:(CYPool *)pool;
- (NSComparisonResult) compareByName:(Source *)source;
@@ -1639,7 +1637,7 @@ static void PackageImport(const void *key, const void *value, void *context) {
return index_;
}
-- (void) setMetaIndex:(metaIndex *)index inPool:(apr_pool_t *)pool {
+- (void) setMetaIndex:(metaIndex *)index inPool:(CYPool *)pool {
trusted_ = index->IsTrusted();
uri_.set(pool, index->GetURI());
@@ -1715,7 +1713,7 @@ static void PackageImport(const void *key, const void *value, void *context) {
authority_ = [url path];
}
-- (Source *) initWithMetaIndex:(metaIndex *)index forDatabase:(Database *)database inPool:(apr_pool_t *)pool {
+- (Source *) initWithMetaIndex:(metaIndex *)index forDatabase:(Database *)database inPool:(CYPool *)pool {
if ((self = [super init]) != nil) {
era_ = [database era];
database_ = database;
@@ -2110,7 +2108,7 @@ struct ParsedPackage {
uint32_t ignored_ : 1;
uint32_t pooled_ : 1;
- apr_pool_t *pool_;
+ CYPool *pool_;
uint32_t rank_;
@@ -2139,8 +2137,8 @@ struct ParsedPackage {
_H<NSMutableArray> tags_;
}
-- (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database;
-+ (Package *) packageWithIterator:(pkgCache::PkgIterator)iterator withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database;
+- (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(CYPool *)pool database:(Database *)database;
++ (Package *) packageWithIterator:(pkgCache::PkgIterator)iterator withZone:(NSZone *)zone inPool:(CYPool *)pool database:(Database *)database;
- (pkgCache::PkgIterator) iterator;
- (void) parse;
@@ -2357,7 +2355,7 @@ struct PackageNameOrdering :
- (void) dealloc {
if (!pooled_)
- apr_pool_destroy(pool_);
+ delete pool_;
if (parsed_ != NULL)
delete parsed_;
[super dealloc];
@@ -2540,11 +2538,11 @@ struct PackageNameOrdering :
_end
} }
-- (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database {
+- (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(CYPool *)pool database:(Database *)database {
if ((self = [super init]) != nil) {
_profile(Package$initWithVersion)
if (pool == NULL)
- apr_pool_create(&pool_, NULL);
+ pool_ = new CYPool();
else {
pool_ = pool;
pooled_ = true;
@@ -2620,7 +2618,7 @@ struct PackageNameOrdering :
char *transform;
_profile(Package$initWithVersion$Transliterate$apr_palloc)
- transform = static_cast<char *>(apr_palloc(pool_, length));
+ transform = pool_->malloc<char>(length);
_end
_profile(Package$initWithVersion$Transliterate$u_strToUTF8WithSub$transform)
u_strToUTF8WithSub(transform, length, NULL, CollationString_.data(), CollationString_.size(), 0xfffd, NULL, &code);
@@ -2719,7 +2717,7 @@ struct PackageNameOrdering :
_end } return self;
}
-+ (Package *) packageWithIterator:(pkgCache::PkgIterator)iterator withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database {
++ (Package *) packageWithIterator:(pkgCache::PkgIterator)iterator withZone:(NSZone *)zone inPool:(CYPool *)pool database:(Database *)database {
pkgCache::VerIterator version;
_profile(Package$packageWithIterator$GetCandidateVer)
@@ -3520,7 +3518,6 @@ class CydiaLogCleaner :
// XXX: actually implement this thing
_assert(false);
[self releasePackages];
- apr_pool_destroy(pool_);
NSRecycleZone(zone_);
[super dealloc];
}
@@ -3651,7 +3648,6 @@ class CydiaLogCleaner :
lock_ = NULL;
zone_ = NSCreateZone(1024 * 1024, 256 * 1024, NO);
- apr_pool_create(&pool_, NULL);
size_t capacity(MetaFile_->active_);
if (capacity == 0)
@@ -3801,7 +3797,8 @@ class CydiaLogCleaner :
cache_.Close();
- apr_pool_clear(pool_);
+ pool_.~CYPool();
+ new (&pool_) CYPool();
NSRecycleZone(zone_);
zone_ = NSCreateZone(1024 * 1024, 256 * 1024, NO);
@@ -3823,7 +3820,7 @@ class CydiaLogCleaner :
_profile(reloadDataWithInvocation$Source$initWithMetaIndex)
for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
- Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]);
+ Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:&pool_] autorelease]);
[sourceList_ addObject:object];
}
_end
@@ -3926,7 +3923,7 @@ class CydiaLogCleaner :
_profile(reloadDataWithInvocation$packageWithIterator)
for (pkgCache::PkgIterator iterator = cache_->PkgBegin(); !iterator.end(); ++iterator)
- if (Package *package = [Package packageWithIterator:iterator withZone:zone_ inPool:pool_ database:self])
+ if (Package *package = [Package packageWithIterator:iterator withZone:zone_ inPool:&pool_ database:self])
//packages.push_back(package);
CFArrayAppendValue(packages_, CFRetain(package));
_end
@@ -10319,9 +10316,6 @@ int main(int argc, char *argv[]) {
CollationStarts_ = [NSArray arrayWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o",@"p",@"q",@"r",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z",@"ʒ",nil];
}
/* }}} */
-
- apr_app_initialize(&argc, const_cast<const char * const **>(&argv), NULL);
-
/* Parse Arguments {{{ */
bool substrate(false);