]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/ltdl.c (N_ELEMENTS): Deleted. How come nobody noticed
authorGary V. Vaughan <gary@gnu.org>
Tue, 14 Aug 2001 23:28:40 +0000 (23:28 +0000)
committerGary V. Vaughan <gary@gnu.org>
Tue, 14 Aug 2001 23:28:40 +0000 (23:28 +0000)
there was no way this could have ever worked?
(lt_dlcaller_set_data): Now that valid caller_ids must be
non-zero, allocate an addition entry in the caller_data vector and
use a zero valued key as the end marker.
(lt_dlcaller_get_data): Iterate up to the end marker in one pass.

ChangeLog
libltdl/ltdl.c

index b80607e68e99b5d2d8469d89a3615643eb72fb3f..26ec25d4f43e857a086bd7c01010ec96c3ef08d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-08-15  Gary V. Vaughan  <gary@gnu.org>
+
+       * libltdl/ltdl.c (N_ELEMENTS):  Deleted.  How come nobody noticed
+       there was no way this could have ever worked?
+       (lt_dlcaller_set_data): Now that valid caller_ids must be
+       non-zero, allocate an addition entry in the caller_data vector and
+       use a zero valued key as the end marker.
+       (lt_dlcaller_get_data): Iterate up to the end marker in one pass.
+
 2001-08-14  Gary V. Vaughan  <gary@gnu.org>
 
        * libltdl/ltdl.c (lt_dlcaller_register): Caller ids are allocated
index ff7e2c7e8036cba30a05aa2a2412821415b53e02..61e3b71587b432532018a637e790a9031525fea4 100644 (file)
@@ -3548,8 +3548,6 @@ lt_dlcaller_register ()
   return result;
 }
 
-#define N_ELEMENTS(a)  (sizeof(a) / sizeof(*(a)))
-
 lt_ptr
 lt_dlcaller_set_data (key, handle, data)
      lt_dlcaller_id key;
@@ -3565,7 +3563,8 @@ lt_dlcaller_set_data (key, handle, data)
   LT_DLMUTEX_LOCK ();
 
   if (handle->caller_data)
-    n_elements = N_ELEMENTS (handle->caller_data);
+    while (handle->caller_data[n_elements].key)
+      ++n_elements;
 
   for (i = 0; i < n_elements; ++i)
     {
@@ -3577,11 +3576,11 @@ lt_dlcaller_set_data (key, handle, data)
     }
 
   /* Ensure that there is enough room in this handle's caller_data
-     array to accept a new element.  */
+     array to accept a new element (and an empty end marker).  */
   if (i == n_elements)
     {
       lt_caller_data *temp
-       = LT_DLREALLOC (lt_caller_data, handle->caller_data, 1+ n_elements);
+       = LT_DLREALLOC (lt_caller_data, handle->caller_data, 2+ n_elements);
 
       if (!temp)
        {
@@ -3593,6 +3592,7 @@ lt_dlcaller_set_data (key, handle, data)
 
       /* We only need this if we needed to allocate a new caller_data.  */
       handle->caller_data[i].key  = key;
+      handle->caller_data[1+ i].key = 0;
     }
 
   handle->caller_data[i].data = data;
@@ -3609,19 +3609,15 @@ lt_dlcaller_get_data  (key, handle)
      lt_dlhandle handle;
 {
   lt_ptr result = (lt_ptr) 0;
-  int n_elements = 0;
 
   /* This needs to be locked so that the caller data isn't updated by
      another thread part way through this function.  */
   LT_DLMUTEX_LOCK ();
 
-  if (handle->caller_data)
-    n_elements = N_ELEMENTS (handle->caller_data);
-
   /* Locate the index of the element with a matching KEY.  */
   {
     int i;
-    for (i = 0; i < n_elements; ++i)
+    for (i = 0; handle->caller_data[i].key; ++i)
       {
        if (handle->caller_data[i].key == key)
          {