Differences From Artifact [fdc15c6565]:
- File src/OFObject.m — part of check-in [8ae4c59cd6] at 2008-10-26 20:54:54 on branch trunk — Return self when we have no return value. This allows nesting. (user: js, size: 2332) [annotate] [blame] [check-ins using]
To Artifact [504a3629c1]:
- File
src/OFObject.m
— part of check-in
[49859c2bcc]
at
2008-10-29 17:29:49
on branch trunk
— Add getMemForNItems:withSize: & resizeMem:toNItems:withSize: in OFObject
Additionally, interface for OFArray. (user: js, size: 2885) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | if (__mem_pool != NULL) __mem_pool->next = iter; __mem_pool = iter; return iter->ptr; } - (void*)resizeMem: (void*)ptr toSize: (size_t)size { struct __ofobject_allocated_mem *iter; for (iter = __mem_pool; iter != NULL; iter = iter->prev) { if (iter->ptr == ptr) { if ((ptr = realloc(iter->ptr, size)) == NULL) { [[OFNoMemException newWithObject: self andSize: size] raise]; | > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | 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 | if (__mem_pool != NULL) __mem_pool->next = iter; __mem_pool = iter; return iter->ptr; } - (void*)getMemForNItems: (size_t)nitems withSize: (size_t)size { size_t memsize; if (size > SIZE_MAX / nitems) { [[OFOverflowException newWithObject: self] raise]; return NULL; } memsize = nitems * size; return [self getMemWithSize: memsize]; } - (void*)resizeMem: (void*)ptr toSize: (size_t)size { struct __ofobject_allocated_mem *iter; for (iter = __mem_pool; iter != NULL; iter = iter->prev) { if (iter->ptr == ptr) { if ((ptr = realloc(iter->ptr, size)) == NULL) { [[OFNoMemException newWithObject: self andSize: size] raise]; return iter->ptr; } iter->ptr = ptr; return ptr; } } [[OFMemNotPartOfObjException newWithObject: self andPointer: ptr] raise]; return NULL; } - (void*)resizeMem: (void*)ptr toNItems: (size_t)nitems ofSize: (size_t)size { size_t memsize; if (size > SIZE_MAX / nitems) { [[OFOverflowException newWithObject: self] raise]; return ptr; } memsize = nitems * size; return [self resizeMem: ptr toSize: memsize]; } - freeMem: (void*)ptr; { struct __ofobject_allocated_mem *iter; for (iter = __mem_pool; iter != NULL; iter = iter->prev) { if (iter->ptr == ptr) { |
︙ | ︙ |