From: Gary V. Vaughan Date: Tue, 14 Aug 2001 23:28:40 +0000 (+0000) Subject: * libltdl/ltdl.c (N_ELEMENTS): Deleted. How come nobody noticed X-Git-Tag: release-1-4d~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3c34e5ca2ad7483d559ec34dea48780dd749499;p=thirdparty%2Flibtool.git * 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. --- diff --git a/ChangeLog b/ChangeLog index b80607e68..26ec25d4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-08-15 Gary V. Vaughan + + * 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 * libltdl/ltdl.c (lt_dlcaller_register): Caller ids are allocated diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index ff7e2c7e8..61e3b7158 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -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) {