This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Even more ObjC cleanup
- To: gcc-patches at gcc dot gnu dot org
- Subject: Even more ObjC cleanup
- From: Stan Shebs <shebs at apple dot com>
- Date: Wed, 20 Jun 2001 18:31:13 -0700
While scanning for error messages to exercise, I noticed that the
result of xmallocs were being checked for nullness. Although it's
reasonable defensive programming, nothing else in GCC does it that
I could see, and there's no easy way to test the code either, so I
took out the checks. Tested on i686-pc-linux-gnu, no regressions in
testsuite.
Stan
2001-06-20 Stan Shebs <shebs@apple.com>
* objc/objc-act.c (hash_init): Assume xmalloc always succeeds,
also use memset to clear the hash tables.
(hash_enter): Assume xmalloc always succeeds.
(hash_add_attr): Ditto.
(continue_class): Ditto.
Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.85
diff -3 -c -p -r1.85 objc-act.c
*** objc-act.c 2001/05/28 01:01:10 1.85
--- objc-act.c 2001/06/20 13:47:19
*************** build_ivar_reference (id)
*** 5447,5467 ****
static void
hash_init ()
{
! nst_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
! cls_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
! if (!nst_method_hash_list || !cls_method_hash_list)
! perror ("unable to allocate space in objc-act.c");
! else
! {
! int i;
!
! for (i = 0; i < SIZEHASHTABLE; i++)
! {
! nst_method_hash_list[i] = 0;
! cls_method_hash_list[i] = 0;
! }
! }
}
/* WARNING!!!! hash_enter is called with a method, and will peek
--- 5447,5457 ----
static void
hash_init ()
{
! nst_method_hash_list = (hash *) xmalloc (SIZEHASHTABLE * sizeof (hash));
! cls_method_hash_list = (hash *) xmalloc (SIZEHASHTABLE * sizeof (hash));
! memset (nst_method_hash_list, 0, SIZEHASHTABLE * sizeof (hash));
! memset (cls_method_hash_list, 0, SIZEHASHTABLE * sizeof (hash));
}
/* WARNING!!!! hash_enter is called with a method, and will peek
*************** hash_enter (hashlist, method)
*** 5484,5491 ****
hash_alloc_index = 0;
hash_alloc_list = (hash) xmalloc (sizeof (struct hashed_entry)
* HASH_ALLOC_LIST_SIZE);
- if (! hash_alloc_list)
- perror ("unable to allocate in objc-act.c");
}
obj = &hash_alloc_list[hash_alloc_index++];
obj->list = 0;
--- 5474,5479 ----
*************** hash_add_attr (entry, value)
*** 5528,5535 ****
attr_alloc_index = 0;
attr_alloc_list = (attr) xmalloc (sizeof (struct hashed_attribute)
* ATTR_ALLOC_LIST_SIZE);
- if (! attr_alloc_list)
- perror ("unable to allocate in objc-act.c");
}
obj = &attr_alloc_list[attr_alloc_index++];
obj->next = entry->list;
--- 5516,5521 ----
*************** continue_class (class)
*** 6309,6317 ****
if (!objc_class_template)
build_class_template ();
! if (!(imp_entry
! = (struct imp_entry *) xmalloc (sizeof (struct imp_entry))))
! perror ("unable to allocate in objc-act.c");
imp_entry->next = imp_list;
imp_entry->imp_context = class;
--- 6295,6301 ----
if (!objc_class_template)
build_class_template ();
! imp_entry = (struct imp_entry *) xmalloc (sizeof (struct imp_entry));
imp_entry->next = imp_list;
imp_entry->imp_context = class;