Overview
Comment: | Use OFList and OFArray in OFAutoreleasePool. This reduces code duplication and looks far better. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
dfc10dbeb86a9c0718200875fb594ac0 |
User & Date: | js on 2009-01-06 22:38:25 |
Other Links: | manifest | tags |
Context
2009-01-07
| ||
17:10 |
Also release the pools when we release the pool list. We need to do that manually as we disabled retain / release for the list. check-in: 03618ea87b user: js tags: trunk | |
2009-01-06
| ||
22:38 |
Use OFList and OFArray in OFAutoreleasePool. This reduces code duplication and looks far better. check-in: dfc10dbeb8 user: js tags: trunk | |
2009-01-05
| ||
22:18 | Reworked OFList. check-in: 8ab6561840 user: js tags: trunk | |
Changes
Modified src/OFArray.h from [02a145515d] to [e7a8933e40].
︙ | |||
66 67 68 69 70 71 72 | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | - + | * \return The last item of the OFArray */ - (void*)last; /** * Adds an item to the OFArray. * |
︙ |
Modified src/OFAutoreleasePool.h from [b23ad42b20] to [d4653e60d0].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | + + - - + + | /* * Copyright (c) 2008 - 2009 * 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 "OFObject.h" #import "OFArray.h" #import "OFList.h" /** * The OFAutoreleasePool class provides a class that keeps track of objects * that will be released when the autorelease pool is released. * Every thread has its own stack of autorelease pools. */ @interface OFAutoreleasePool: OFObject { |
︙ | |||
37 38 39 40 41 42 43 | 39 40 41 42 43 44 45 46 47 | - + - - - - - | * \param obj The object to add to the autorelease pool */ - addToPool: (OFObject*)obj; /** * Releases all objects in the autorelease pool. */ |
Modified src/OFAutoreleasePool.m from [e28fa49a4f] to [8a91012795].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | + + - - + + + + - + - - + - - - - - - + - - - - - + - - - + - - - - - - - + - - - - - - - - + - - + - - - - - - - - + - + - - + - - + - - - - - - + - - - + - - + - - - - + - - - - - + - - - - - - - - - - - - - - - + - - - + - - + + - + - - - - + + + - - - - + + + - - - + - + - + + - + - - + - - + + + + + + - + - - - - - - | #ifndef _WIN32 #import <pthread.h> #endif #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "OFList.h" #ifdef _WIN32 #import <windows.h> #endif #ifndef _WIN32 #define get_tls(t) pthread_getspecific(pool_list_key) |
Modified src/OFList.h from [8e66167c8d] to [439fd52763].
︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + + + + + + + + + + | /** * The OFList class provides easy to use double-linked lists. */ @interface OFList: OFObject { of_list_object_t *first; of_list_object_t *last; BOOL retain_and_release; } /** * Initializes an already allocated OFList. * * \param enabled Whether release / retain should be called when an object is * added / removed. Default: YES * \return An initialized OFList */ - initWithRetainAndReleaseEnabled: (BOOL)enabled; /** * \return The first object in the list */ - (of_list_object_t*)first; /** * \return The last object in the list |
︙ |
Modified src/OFList.m from [55395f28ca] to [f248439ac0].
︙ | |||
14 15 16 17 18 19 20 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + + + + + + + + + + + + + | #import "OFList.h" @implementation OFList - init { if ((self = [super init])) { first = NULL; |
︙ | |||
55 56 57 58 59 60 61 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | + - + + + - + + + - + + + - + + + + + + | if (last != NULL) last->next = o; last = o; if (first == NULL) first = o; if (retain_and_release) |
Modified src/OFObject.h from [743bd758c4] to [8a674581d8].
︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + + + + + | - release; /** * Adds the object to the autorelease pool that is on top of the thread's stack. */ - autorelease; /** * \return The retain count */ - (size_t)retainCount; /** * Adds a pointer to the memory pool. * This is useful to add memory allocated by functions such as asprintf to the * pool so it gets freed automatically when the object is freed. * * \param ptr A pointer to add to the memory pool */ |
︙ |
Modified src/OFObject.m from [c1018bac67] to [f1ae449a76].
︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + + + + + | - autorelease { [OFAutoreleasePool addToPool: self]; return self; } - (size_t)retainCount { return __retain_count; } - addToMemoryPool: (void*)ptr { void **memchunks; size_t memchunks_size; memchunks_size = __memchunks_size + 1; |
︙ |
Modified tests/OFArray/OFArray.m from [f659184241] to [211a3acfce].
︙ | |||
95 96 97 98 99 100 101 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | - + | \ [a free]; \ \ puts("Creating new array and using it to build a string..."); \ a = [type newWithItemSize: 1]; \ \ for (i = 0; i < strlen(str); i++) \ |
︙ |
Modified tests/OFAutoreleasePool/OFAutoreleasePool.m from [a5d1f5a43b] to [389325218a].
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | * the packaging of this file. */ #import "config.h" #import "OFAutoreleasePool.h" #import <stdio.h> |
︙ |