-
- j->sel_id = (void *) i;
- /* Can we use the pointer or must copy types? Don't copy if NULL */
- if ((is_const) || (types == 0))
- j->sel_types = (const char *) types;
- else {
- j->sel_types = (char *) objc_malloc (strlen (types) + 1);
- strcpy ((char *) j->sel_types, types);
- }
+
+ j->sel_id = (void *)i;
+ /* Can we use the pointer or must we copy types ? Don't copy if
+ NULL. */
+ if (is_const || (types == 0))
+ j->sel_types = types;
+ else
+ {
+ j->sel_types = (char *)objc_malloc (strlen (types) + 1);
+ strcpy ((char *)j->sel_types, types);
+ }
+
+ /* Since this is the first selector with this name, we need to
+ register the correspondence between 'i' (the sel_id) and
+ 'name' (the actual string) in __objc_selector_names and
+ __objc_selector_hash. */
+
+ /* Can we use the pointer or must we copy name ? Don't copy if
+ NULL. (FIXME: Can the name really be NULL here ?) */
+ if (is_const || (name == 0))
+ new_name = name;
+ else
+ {
+ new_name = (char *)objc_malloc (strlen (name) + 1);
+ strcpy ((char *)new_name, name);
+ }
+
+ /* This maps the sel_id to the name. */
+ sarray_at_put_safe (__objc_selector_names, i, (void *)new_name);
+
+ /* This maps the name to the sel_id. */
+ objc_hash_add (&__objc_selector_hash, (void *)new_name, (void *)i);
+