Tweak the ManyManySelectors test case so that it doesn't hit a pathological

case in the selector hashing function and use insane amounts of memory.
main
theraven 13 years ago
parent 1b7a492ab2
commit 0e90d9645d

@ -3,25 +3,33 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
static BOOL methodCalled = NO; static BOOL methodCalled = NO;
static char selBuffer[] = "XXXXXXXselectorXXXXXXXX";
static id x(id self, SEL _cmd) static id x(id self, SEL _cmd)
{ {
methodCalled = YES; methodCalled = YES;
assert(strcmp("selectoreffff", sel_getName(_cmd)) == 0); assert(strcmp(selBuffer, sel_getName(_cmd)) == 0);
return self; return self;
} }
int main(void) int main(void)
{ {
char selBuffer[] = "selectorXXXXXXXX";
SEL nextSel; SEL nextSel;
Class cls = [Test class]; Class cls = [Test class];
assert(cls != Nil); assert(cls != Nil);
int sel_size = 0;
for (uint32_t i=0 ; i<0xf0000 ; i++) for (uint32_t i=0 ; i<0xf0000 ; i++)
{ {
snprintf(selBuffer, 16, "selector%" PRIx32, i); snprintf(selBuffer, 16, "%" PRId32 "selector%" PRIx32, i, i);
nextSel = sel_registerName(selBuffer); nextSel = sel_registerName(selBuffer);
sel_size += strlen(selBuffer);
} }
assert(class_addMethod(object_getClass([Test class]), nextSel, (IMP)x, "@@:")); assert(class_addMethod(object_getClass([Test class]), nextSel, (IMP)x, "@@:"));
assert(cls == [Test class]); assert(cls == [Test class]);
@ -33,3 +41,4 @@ int main(void)
assert(methodCalled == YES); assert(methodCalled == YES);
return 0; return 0;
} }

Loading…
Cancel
Save