Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -225,10 +225,15 @@ * \param index The index at which the items are removed */ - (void)removeNItems: (size_t)nItems atIndex: (size_t)index; +/** + * \brief Removes the last item. + */ +- (void)removeLastItem; + /** * \brief Returns a string containing the data in Base64 encoding. * * \return A string containing the data in Base64 encoding */ Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -310,10 +310,23 @@ } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e release]; } } + +- (void)removeLastItem +{ + count--; + @try { + data = [self resizeMemory: data + toNItems: count + withSize: itemSize]; + } @catch (OFOutOfMemoryException *e) { + /* We don't care, as we only made it smaller */ + [e release]; + } +} - copy { OFDataArray *copy = [[OFDataArray alloc] initWithItemSize: itemSize]; Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -109,14 +109,19 @@ * \param index The index at which the objects are removed */ - (void)removeNObjects: (size_t)nObjects atIndex: (size_t)index; +/** + * \brief Removes the last object. + */ +- (void)removeLastObject; + #ifdef OF_HAVE_BLOCKS /** * \brief Replaces each object with the object returned by the block. * * \param block The block which returns a new object for each object */ - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block; #endif @end Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -188,10 +188,19 @@ [copy[i] release]; } @finally { [self freeMemory: copy]; } } + +- (void)removeLastObject +{ + id object = [self objectAtIndex: [array count] - 1]; + [array removeLastItem]; + [object release]; + + mutations++; +} - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ { Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -119,11 +119,11 @@ if ([stack count] == 1) [delegate elementBuilder: self didBuildElement: [stack firstObject]]; - [stack removeNObjects: 1]; + [stack removeLastObject]; } - (void)parser: (OFXMLParser*)parser foundCharacters: (OFString*)characters { Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -634,11 +634,11 @@ if (![[previous lastObject] isEqual: cache]) @throw [OFMalformedXMLException newWithClass: isa parser: self]; - [previous removeNObjects: 1]; + [previous removeLastObject]; [cache setToCString: ""]; ns = namespace_for_prefix(prefix, namespaces); if (prefix != nil && ns == nil) @@ -657,11 +657,11 @@ withPrefix: prefix namespace: ns]; [pool release]; - [namespaces removeNObjects: 1]; + [namespaces removeLastObject]; [name release]; [prefix release]; name = prefix = nil; *last = *i + 1; @@ -732,11 +732,11 @@ namespace: ns]; if ([previous count] == 0) finishedParsing = YES; - [namespaces removeNObjects: 1]; + [namespaces removeLastObject]; } else if (prefix != nil) { OFString *str = [OFString stringWithFormat: @"%@:%@", prefix, name]; [previous addObject: str]; } else