Differences From Artifact [43d183da0e]:
- File src/runtime/autorelease.m — part of check-in [5abd9baa33] at 2012-07-16 12:19:59 on branch trunk — Free memory when the last pool has been drained. (user: js, size: 3080) [annotate] [blame] [check-ins using]
To Artifact [c7e0c15de1]:
- File
src/runtime/autorelease.m
— part of check-in
[345eb93240]
at
2012-07-17 01:09:50
on branch trunk
— Rename ERROR() to OBJC_ERROR().
ERROR seems to be defined on MinGW32 and it's likely that it's also used
on other systems, thus it's better to prefix it with OBJC_. (user: js, size: 3125) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | static of_tlskey_t objectsKey, topKey, sizeKey; static void __attribute__((constructor)) init(void) { if (!of_tlskey_new(&objectsKey) || !of_tlskey_new(&sizeKey) || !of_tlskey_new(&topKey)) | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | static of_tlskey_t objectsKey, topKey, sizeKey; static void __attribute__((constructor)) init(void) { if (!of_tlskey_new(&objectsKey) || !of_tlskey_new(&sizeKey) || !of_tlskey_new(&topKey)) OBJC_ERROR("Unable to create TLS key for autorelease pools!") } #endif id objc_autorelease(id object) { return [object autorelease]; |
︙ | ︙ | |||
83 84 85 86 87 88 89 | objects = NULL; top = NULL; } #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects) ||!of_tlskey_set(topKey, top)) | | | | | | | | | | 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 | objects = NULL; top = NULL; } #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects) ||!of_tlskey_set(topKey, top)) OBJC_ERROR("Failed to set TLS key!") #endif } id _objc_rootAutorelease(id object) { #ifndef OF_COMPILER_TLS id *top = of_tlskey_get(topKey); id *objects = of_tlskey_get(objectsKey); size_t size = (size_t)(uintptr_t)of_tlskey_get(sizeKey); #endif if (objects == NULL) { if ((objects = malloc(of_pagesize)) == NULL) OBJC_ERROR("Out of memory for autorelease pools!") #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects)) OBJC_ERROR("Failed to set TLS key!") if (!of_tlskey_set(sizeKey, (void*)(uintptr_t)of_pagesize)) OBJC_ERROR("Failed to set TLS key!") #endif top = objects; size = of_pagesize; } if ((uintptr_t)top >= (uintptr_t)objects + size) { ptrdiff_t diff = top - objects; size += of_pagesize; if ((objects = realloc(objects, size)) == NULL) OBJC_ERROR("Out of memory for autorelease pools!") #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects)) OBJC_ERROR("Failed to set TLS key!") if (!of_tlskey_set(sizeKey, (void*)(uintptr_t)size)) OBJC_ERROR("Failed to set TLS key!") #endif top = objects + diff; } *top = object; top++; #ifndef OF_COMPILER_TLS if (!of_tlskey_set(topKey, objects)) OBJC_ERROR("Failed to set TLS key!") #endif return object; } |