From 5b424d69690f7e05650ec94b318f3ff2e2a1aa11 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 16 Mar 2012 20:53:04 +0000 Subject: [PATCH] Monotone-Parent: cd4c34d79c62c8b6a1f9ccfb14ea9a79442034c6 Monotone-Revision: ff50144aaefa18bc1bf88723bc25f1f6b4962451 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-16T20:53:04 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ OpenChange/MAPIStoreSOGo.m | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index 88eb73a8a..2036b55f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-03-16 Wolfgang Sourdeau + * OpenChange/MAPIStoreSOGo.m (sogo_backend_init): check for + "SOGoDebugLeaks" in the user defaults and activate GSDebug + allocation utilities. + * OpenChange/NSData+MAPIStore.m (+dataWithChangeKeyGUID:andCnt:): new method replacing _dataFromChangeKeyGUID:andCnt: from MAPIStore{GCS,Mail}Folder. diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index 69df2ffc5..f2b6a807e 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -23,6 +23,7 @@ /* OpenChange SOGo storage backend */ #import +#import #import #import #import @@ -48,6 +49,7 @@ #include static Class MAPIStoreContextK = Nil; +static BOOL leakDebugging = NO; static enum mapistore_error sogo_backend_unexpected_error() @@ -57,6 +59,16 @@ sogo_backend_unexpected_error() return MAPISTORE_SUCCESS; } +static void +sogo_backend_atexit (void) +{ + NSAutoreleasePool *pool; + + pool = [NSAutoreleasePool new]; + NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES)); + [pool release]; +} + /** \details Initialize sogo mapistore backend @@ -89,6 +101,14 @@ sogo_backend_init (void) ud = [NSUserDefaults standardUserDefaults]; [ud registerDefaults: [ud persistentDomainForName: @"sogod"]]; + if (!leakDebugging && [ud boolForKey: @"SOGoDebugLeaks"]) + { + NSLog (@" leak debugging on"); + GSDebugAllocationActive (YES); + atexit (sogo_backend_atexit); + leakDebugging = YES; + } + registry = [SoProductRegistry sharedProductRegistry]; [registry scanForProductsInDirectory: SOGO_BUNDLES_DIR];