From 94383388101170742989e188e020f91b81a2ddfe Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 3 Feb 2008 23:21:48 +0100 Subject: Glue layer: Add slot handling functions. darcs-hash:27035c01db5e23dc0c8c9786ded92aa6e564e6d4 --- Objective-C/libobjcl.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index f49d502..7c1c186 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -406,10 +406,15 @@ objcl_class_direct_slots (Class class, unsigned int *count, unsigned int *elemen #ifdef __NEXT_RUNTIME__ ivars = class_copyIvarList (class, count); #else - *count = class->ivars->ivar_count; - ivars = malloc ((*count) * (*element_size)); - for (i = 0; i < *count; i++) - ivars[i] = &class->ivars->ivar_list[i]; + *count = (class->ivars ? class->ivars->ivar_count : 0); + if (!*count) + ivars = NULL; + else + { + ivars = malloc ((*count) * (*element_size)); + for (i = 0; i < *count; i++) + ivars[i] = &class->ivars->ivar_list[i]; + } #endif return ivars; -- cgit v1.2.3