diff --git a/ChangeLog b/ChangeLog index b3dce5208..06e7395e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-06-03 Wolfgang Sourdeau + * Main/NSException+Stacktrace.m, SOPE/NGCards/NGCardsSaxHandler.m, + SOPE/NGCards/NSString+NGCards.m, + SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m, + SoObjects/Appointments/SOGoAppointmentFolder.m, + SoObjects/SOGo/NSArray+Utilities.m, + SoObjects/SOGo/SOGoGCSFolder.m, + SoObjects/SOGo/SOGoLDAPUserDefaults.m, + UI/MailPartViewers/UIxMailPartTextViewer.m, + UI/MainUI/SOGoUserHomePage.m, UI/Scheduler/UIxCalListingActions.m: + replaced all invocations of "malloc", "realloc", "free" by similar + invocations to NSZoneMalloc, NSZoneRealloc and NSZoneFree. + * SoObjects/Appointments/SOGoAppointmentFolder.m (+initialize): removed obsolete security declarations. (-davCalendarQuery, -davCalendarMultiget): delegate conversion of diff --git a/Main/NSException+Stacktrace.m b/Main/NSException+Stacktrace.m index 8fac8800e..02c39b3a9 100644 --- a/Main/NSException+Stacktrace.m +++ b/Main/NSException+Stacktrace.m @@ -235,7 +235,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception) } if (_symbols) { - objc_free (_symbols); + NSZoneFree (NULL, _symbols); _symbols = NULL; } [super dealloc]; @@ -301,7 +301,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception) [self release]; return nil; } - _symbols = objc_malloc (neededSpace); + _symbols = NSZoneMalloc (NULL, neededSpace); if (!_symbols) { //NSLog (@"GSBinaryFileInfo: Can't allocate buffer"); diff --git a/SOPE/NGCards/NGCardsSaxHandler.m b/SOPE/NGCards/NGCardsSaxHandler.m index 5f1cf0926..102eb5a35 100644 --- a/SOPE/NGCards/NGCardsSaxHandler.m +++ b/SOPE/NGCards/NGCardsSaxHandler.m @@ -219,8 +219,8 @@ return contentValues; } -- (void) characters:(unichar *)_chars - length:(int)_len +- (void) characters: (unichar *) _chars + length: (int) _len { if (_len && _chars) { @@ -228,14 +228,16 @@ { /* first content */ contentLength = _len; - content = calloc (_len + 1, sizeof(unichar)); - memcpy (content, _chars, (_len * sizeof(unichar))); + content = NSZoneMalloc (NULL, (_len + 1) * sizeof (unichar)); + memcpy (content, _chars, (_len * sizeof (unichar))); + *(content + _len) = 0; } else { /* increase content */ content = - realloc (content, (contentLength + _len+2) * sizeof(unichar)); + NSZoneRealloc (NULL, content, + (contentLength + _len+2) * sizeof(unichar)); memcpy (&(content[contentLength]), _chars, (_len * sizeof(unichar))); contentLength += _len; diff --git a/SOPE/NGCards/NSString+NGCards.m b/SOPE/NGCards/NSString+NGCards.m index c22c88dc4..7efc7b89b 100644 --- a/SOPE/NGCards/NSString+NGCards.m +++ b/SOPE/NGCards/NSString+NGCards.m @@ -295,7 +295,7 @@ static NSString *commaSeparator = nil; components = [NSMutableArray array]; length = [self length]; - stringBuffer = malloc (sizeof (unichar) * length); + stringBuffer = NSZoneMalloc (NULL, sizeof (unichar) * length); [self getCharacters: stringBuffer]; currentRange = NSMakeRange(0, 0); @@ -324,7 +324,7 @@ static NSString *commaSeparator = nil; [components addObject: [self substringWithRange: currentRange]]; - free (stringBuffer); + NSZoneFree (NULL, stringBuffer); return components; } diff --git a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m index 38ff8bffa..fef59b9b4 100644 --- a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m +++ b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m @@ -108,7 +108,7 @@ } datalen = [_data length]; - data = calloc(datalen + 1, sizeof(unichar)); + data = NSZoneCalloc (NULL, datalen + 1, sizeof(unichar)); [_data getCharacters: data range: NSMakeRange(0, datalen)]; return self; } @@ -119,7 +119,7 @@ } - (void) dealloc { - if (data) free (data); + if (data) NSZoneFree (NULL, data); [group release]; [tagName release]; [attrs release]; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index e4cb816bd..2c2b4dbd5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1104,7 +1104,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir mgr = [SoSecurityManager sharedSecurityManager]; //c = [self objectClassForComponentName: [object objectForKey: @"c_component"]]; - sogoObject = [SOGoCalendarComponent objectWithRecord: object inContainer: self]; + sogoObject = [SOGoCalendarComponent objectWithRecord: object + inContainer: self]; [sogoObject setComponentTag: [object objectForKey: @"c_component"]]; //sogoObject = [self _createChildComponentWithRecord: object]; diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index 70bc416d0..857371f07 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -35,7 +35,7 @@ unsigned int max; max = [self count]; - pointers = malloc (sizeof(id) * (max + 1)); + pointers = NSZoneMalloc (NULL, sizeof(id) * (max + 1)); [self getObjects: pointers]; *(pointers + max) = nil; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 1eea96e48..c2776fff8 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -834,7 +834,7 @@ static NSArray *childRecordFields = nil; { aclsForObject = [NSMutableDictionary dictionary]; [aclCache setObject: aclsForObject - forKey: objectPath]; + forKey: objectPath]; } if (roles) [aclsForObject setObject: roles forKey: uid]; @@ -871,13 +871,13 @@ static NSArray *childRecordFields = nil; // let's go get the system-wide defaults, if any. if (![acls count]) { - if ([[container nameInContainer] isEqualToString: @"Calendar"] || - [[container nameInContainer] isEqualToString: @"Contacts"]) + if ([[container nameInContainer] isEqualToString: @"Calendar"] + || [[container nameInContainer] isEqualToString: @"Contacts"]) acls = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"SOGo%@DefaultRoles", [container nameInContainer]]]; } - + return acls; } diff --git a/SoObjects/SOGo/SOGoLDAPUserDefaults.m b/SoObjects/SOGo/SOGoLDAPUserDefaults.m index 8f1638457..86ee6e89f 100644 --- a/SoObjects/SOGo/SOGoLDAPUserDefaults.m +++ b/SoObjects/SOGo/SOGoLDAPUserDefaults.m @@ -57,7 +57,7 @@ _createAtom (_SOGoLDAPValueType type, void *value) { _SOGoLDAPValue *newAtom; - newAtom = malloc (sizeof (_SOGoLDAPValue)); + newAtom = NSZoneMalloc (NULL, sizeof (_SOGoLDAPValue)); newAtom->type = type; newAtom->value = value; newAtom->maxCount = 0; @@ -72,7 +72,8 @@ _createContainer (_SOGoLDAPValueType type) _SOGoLDAPValue *newContainer; _SOGoLDAPValue **array; - array = malloc (sizeof (_SOGoLDAPValue *) * SOGoLDAPContainerSize); + array = NSZoneMalloc (NULL, + sizeof (_SOGoLDAPValue *) * SOGoLDAPContainerSize); *array = NULL; newContainer = _createAtom (type, array); newContainer->maxCount = SOGoLDAPContainerSize - 1; /* all values + NULL */ @@ -95,8 +96,9 @@ _appendAtomToContainer (_SOGoLDAPValue *atom, _SOGoLDAPValue *container) if (count >= container->maxCount) { container->maxCount += SOGoLDAPContainerSize; - container->value = realloc (container->value, (container->maxCount + 1) - * sizeof (_SOGoLDAPValue *)); + container->value = NSZoneRealloc (NULL, container->value, + (container->maxCount + 1) + * sizeof (_SOGoLDAPValue *)); currentAtom = (_SOGoLDAPValue **) container->value + count; } @@ -149,7 +151,7 @@ _appendAtomToDictionary (_SOGoLDAPValue *atom, _SOGoLDAPValue *dictionary) if (container->type == SOGoLDAPArray) { - free (atom->key); + NSZoneFree (NULL, atom->key); atom->key = NULL; } _appendAtomToContainer (atom, container); @@ -170,7 +172,8 @@ _fetchLDAPDNAndAttrWithHandle (const char *dn, char *attrs[], LDAP *ldapHandle) _SOGoLDAPValue **atoms, **currentAtom; unsigned int atomsCount; - atoms = malloc (SOGoLDAPContainerSize * sizeof (_SOGoLDAPValue *)); + atoms = NSZoneMalloc (NULL, + SOGoLDAPContainerSize * sizeof (_SOGoLDAPValue *)); currentAtom = atoms; atomsCount = 0; @@ -204,10 +207,10 @@ _fetchLDAPDNAndAttrWithHandle (const char *dn, char *attrs[], LDAP *ldapHandle) if (!(atomsCount % SOGoLDAPContainerSize)) { - atoms = realloc (atoms, (int) - (SOGoLDAPContainerSize + atomsCount) - * sizeof (_SOGoLDAPValue *)); - + atoms = NSZoneRealloc (NULL, atoms, + (int) (SOGoLDAPContainerSizee + + atomsCount) + * sizeof (_SOGoLDAPValue *)); currentAtom = atoms + atomsCount; } value++; @@ -255,7 +258,7 @@ _readLDAPAttrRefWithHandle (const char *attrPair, LDAP *ldapHandle) attrs[1] = NULL; atoms = _fetchLDAPDNAndAttrWithHandle (dn, attrs, ldapHandle); refValue = *atoms; - free (attrs[0]); + NSZoneFree (NULL, attrs[0]); } else { @@ -263,8 +266,8 @@ _readLDAPAttrRefWithHandle (const char *attrPair, LDAP *ldapHandle) atoms = _fetchLDAPDNAndAttrWithHandle (dn, NULL, ldapHandle); _fillLDAPDictionaryWithAtoms (refValue, atoms); } - free (atoms); - free (dn); + NSZoneFree (NULL, atoms); + NSZoneFree (NULL, dn); return refValue; } @@ -378,7 +381,7 @@ _initLDAPDefaults () { atoms = _fetchLDAPDNAndAttrWithHandle (configDN, NULL, ldapHandle); _fillLDAPDictionaryWithAtoms (dictionary, atoms); - free (atoms); + NSZoneFree (NULL, atoms); } return dictionary; diff --git a/UI/MailPartViewers/UIxMailPartTextViewer.m b/UI/MailPartViewers/UIxMailPartTextViewer.m index 99df539f4..b2cbe9ecf 100644 --- a/UI/MailPartViewers/UIxMailPartTextViewer.m +++ b/UI/MailPartViewers/UIxMailPartTextViewer.m @@ -55,7 +55,7 @@ convertChars (const char *oldString, unsigned int oldLength, unsigned int length, maxLength; maxLength = oldLength + paddingBuffer; - newString = malloc (maxLength + 1); + newString = NSZoneMalloc (NULL, maxLength + 1); destChar = newString; currentChar = oldString; @@ -72,7 +72,7 @@ convertChars (const char *oldString, unsigned int oldLength, if (length + paddingBuffer > maxLength - 6) { maxLength += paddingBuffer; - reallocated = realloc (newString, maxLength + 1); + reallocated = NSZoneRealloc (NULL, newString, maxLength + 1); if (reallocated) { newString = reallocated; @@ -112,7 +112,7 @@ convertChars (const char *oldString, unsigned int oldLength, length: newLength encoding: NSUTF8StringEncoding]; [convertedString autorelease]; - free (newString); + NSZoneFree (NULL, newString); return convertedString; } diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index fc4475bb6..793d0878b 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -183,7 +183,7 @@ static NSString *LDAPContactInfoAttribute = nil; interval = [endDate timeIntervalSinceDate: startDate] + 60; intervals = interval / intervalSeconds; /* slices of 15 minutes */ - freeBusyItems = calloc (intervals, sizeof (int)); + freeBusyItems = NSZoneCalloc (NULL, intervals, sizeof (int)); [self _fillFreeBusyItems: freeBusyItems count: intervals withRecords: [fb fetchFreeBusyInfosFrom: startDate to: endDate] fromStartDate: startDate toEndDate: endDate]; @@ -192,7 +192,7 @@ static NSString *LDAPContactInfoAttribute = nil; for (count = 0; count < intervals; count++) [response appendFormat: @"%d,", *(freeBusyItems + count)]; [response deleteCharactersInRange: NSMakeRange (intervals * 2 - 1, 1)]; - free (freeBusyItems); + NSZoneFree (NULL, freeBusyItems); return response; } diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index f49576ab8..32c7bd8d7 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -761,7 +761,7 @@ _computeBlockPosition (NSArray *block) max = [block count]; event = [block objectAtIndex: 0]; siblings = [[event objectForKey: @"siblings"] unsignedIntValue]; - positions = calloc (siblings, sizeof (NSMutableDictionary *)); + positions = NSZoneCalloc (NULL, siblings, sizeof (NSMutableDictionary *)); for (count = 0; count < max; count++) { @@ -780,7 +780,7 @@ _computeBlockPosition (NSArray *block) } } - free (positions); + NSZoneFree (NULL, positions); } // static inline void @@ -831,7 +831,7 @@ _computeBlocksPosition (NSArray *blocks) block = [blocks objectAtIndex: count]; _computeBlockPosition (block); // _addBlockMultipliers (block, positions); -// free (positions); +// NSZoneFree (NULL, positions); } }