Artifact 361533dbeb45cacdb50b2969a4331f5f9f9d5dc0ae8d5901de0a136ad20648eb:
- File
src/OFList.m
— part of check-in
[7a49441656]
at
2008-10-09 00:25:31
on branch trunk
— Multiple changes, see details.
* Use config.h.
* Check whether to use sel_get_name or sel_getName.
* Rename freeWithData to freeIncludingData. (user: js, size: 1118) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #import "OFList.h" @implementation OFList - init { if ((self = [super init])) { first = nil; last = nil; } return self; } - free { OFListObject *iter, *next; for (iter = first; iter != nil; iter = next) { next = [iter next]; [iter free]; } return [super free]; } - freeIncludingData { OFListObject *iter, *next; for (iter = first; iter != nil; iter = next) { next = [iter next]; [iter freeIncludingData]; } first = last = nil; return [super free]; } - (OFListObject*)first { return first; } - (OFListObject*)last { return last; } - (void)add: (OFListObject*)ptr { if (!first || !last) { first = last = ptr; return; } [ptr setPrev: last]; [last setNext: ptr]; last = ptr; } - (void)addNew: (void*)ptr { return [self add: [OFListObject newWithData: ptr]]; } @end