diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-24 20:10:46 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-24 20:10:46 +0000 |
commit | 53f87f101af3cc1c05543b3ec46ee2e455bd6fa9 (patch) | |
tree | 82ccf00b97041686d44ec777ecbed412ef03db12 /libobjc | |
parent | f3031d3508b1b727dfef911f7ba6cf1e5a0d4e6b (diff) | |
download | gcc-53f87f101af3cc1c05543b3ec46ee2e455bd6fa9.tar.gz |
In libobjc/:
2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
* selector.c (sel_getTypedSelector): Return NULL if given a NULL
argument.
(sel_registerTypedName): Same.
(sel_registerName): Same.
* objc/runtime.h: Updated documentation.
In gcc/testsuite/:
2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/gnu-api-2-sel.m: Test calling sel_getUid,
sel_registerName and sel_registerTypedName with NULL arguments.
Updated the test to work with the Apple runtime as well.
* obj-c++.dg/gnu-api-2-sel.mm: Same change.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168231 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 8 | ||||
-rw-r--r-- | libobjc/objc/runtime.h | 6 | ||||
-rw-r--r-- | libobjc/selector.c | 12 |
3 files changed, 22 insertions, 4 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index d8f23f74c9a..f234a2654d1 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,13 @@ 2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com> + * selector.c (sel_getTypedSelector): Return NULL if given a NULL + argument. + (sel_registerTypedName): Same. + (sel_registerName): Same. + * objc/runtime.h: Updated documentation. + +2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com> + * objc/runtime.h (class_addIvar): Updated documentation. The alignment is actually the log_2 of the alignment in bytes. * ivars.c (class_addIvar): Corresponding change to the diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index 9332f7be069..551c348d307 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -191,14 +191,14 @@ objc_EXPORT SEL sel_getUid (const char *name); you know the types, it is better to call sel_registerTypedName(). If a selector with this name and no types already exists, it is returned. Note that this function should really be called - 'objc_registerSelector'. */ + 'objc_registerSelector'. Return NULL if 'name' is NULL. */ objc_EXPORT SEL sel_registerName (const char *name); /* Register a selector with a given name and types. If a selector with this name and types already exists, it is returned. Note that this function should really be called 'objc_registerTypedSelector', and it's called 'sel_registerTypedName' only for consistency with - 'sel_registerName'. + 'sel_registerName'. Return NULL if 'name' is NULL. Compatibility Note: the Apple/NeXT runtime has untyped selectors, so it does not have this function, which is specific to the GNU @@ -227,7 +227,7 @@ objc_EXPORT SEL * sel_copyTypedSelectorList (const char *name, /* Return a selector with name 'name' and a non-zero type encoding, if any such selector is registered with the runtime. If there is no - such selector, NULL is returned. + such selector, NULL is returned. Return NULL if 'name' is NULL. This is useful if you have the name of the selector, and would really like to get a selector for it that includes the type diff --git a/libobjc/selector.c b/libobjc/selector.c index f8a7f14fdb1..4110df2662b 100644 --- a/libobjc/selector.c +++ b/libobjc/selector.c @@ -357,8 +357,12 @@ SEL sel_getTypedSelector (const char *name) { sidx i; - objc_mutex_lock (__objc_runtime_mutex); + if (name == NULL) + return NULL; + + objc_mutex_lock (__objc_runtime_mutex); + /* Look for a typed selector. */ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name); if (i != 0) @@ -658,6 +662,9 @@ SEL sel_registerName (const char *name) { SEL ret; + + if (name == NULL) + return NULL; objc_mutex_lock (__objc_runtime_mutex); /* Assume that name is not constant static memory and needs to be @@ -680,6 +687,9 @@ sel_registerTypedName (const char *name, const char *type) { SEL ret; + if (name == NULL) + return NULL; + objc_mutex_lock (__objc_runtime_mutex); /* Assume that name and type are not constant static memory and need to be copied before put into a runtime structure. is_const == |