/[m4]/m4/m4/ltdl.c
ViewVC logotype

Diff of /m4/m4/ltdl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by gary, Mon Aug 13 23:37:44 2001 UTC revision 1.8 by gary, Thu Aug 16 22:21:30 2001 UTC
# Line 451  argz_create_sep (str, delim, pargz, parg Line 451  argz_create_sep (str, delim, pargz, parg
451    
452    /* Make a copy of STR, but replacing each occurence of    /* Make a copy of STR, but replacing each occurence of
453       DELIM with '\0'.  */       DELIM with '\0'.  */
454    argz_len = LT_STRLEN (str);    argz_len = 1+ LT_STRLEN (str);
455    if (argz_len)    if (argz_len)
456      {      {
457        const char *p;        const char *p;
458        char *q;        char *q;
459    
460        argz = LT_DLMALLOC (char, 1+ argz_len);        argz = LT_DLMALLOC (char, argz_len);
461        if (!argz)        if (!argz)
462          return ENOMEM;          return ENOMEM;
463    
# Line 475  argz_create_sep (str, delim, pargz, parg Line 475  argz_create_sep (str, delim, pargz, parg
475            else            else
476              *q++ = *p;              *q++ = *p;
477          }          }
478          /* Copy terminating LT_EOS_CHAR.  */
479          *q = *p;
480      }      }
481    
482    /* If ARGZ_LEN has shrunk to nothing, release ARGZ's memory.  */    /* If ARGZ_LEN has shrunk to nothing, release ARGZ's memory.  */
# Line 613  argz_stringify (argz, argz_len, sep) Line 615  argz_stringify (argz, argz_len, sep)
615    
616    if (sep)    if (sep)
617      {      {
618        while (--argz_len >= 0)        --argz_len;               /* don't stringify the terminating EOS */
619          while (--argz_len > 0)
620          {          {
621            if (argz[argz_len] == LT_EOS_CHAR)            if (argz[argz_len] == LT_EOS_CHAR)
622              argz[argz_len] = sep;              argz[argz_len] = sep;
# Line 824  lt_dlseterror (errindex) Line 827  lt_dlseterror (errindex)
827    else if (errindex < LT_ERROR_MAX)    else if (errindex < LT_ERROR_MAX)
828      {      {
829        /* No error setting the error message! */        /* No error setting the error message! */
830        LT_DLMUTEX_SETERROR (lt_dlerror_strings[errorcount]);        LT_DLMUTEX_SETERROR (lt_dlerror_strings[errindex]);
831      }      }
832    else    else
833      {      {
834        /* No error setting the error message! */        /* No error setting the error message! */
835        LT_DLMUTEX_SETERROR (user_error_strings[errorcount - LT_ERROR_MAX]);        LT_DLMUTEX_SETERROR (user_error_strings[errindex - LT_ERROR_MAX]);
836      }      }
837    
838    LT_DLMUTEX_UNLOCK ();    LT_DLMUTEX_UNLOCK ();
# Line 3504  lt_dlhandle Line 3507  lt_dlhandle
3507  lt_dlhandle_next (place)  lt_dlhandle_next (place)
3508       lt_dlhandle place;       lt_dlhandle place;
3509  {  {
3510    return place ? place->next : (lt_dlhandle) 0;    return place ? place->next : handles;
3511  }  }
3512    
3513  int  int
# Line 3538  lt_dlforeach (func, data) Line 3541  lt_dlforeach (func, data)
3541  lt_dlcaller_id  lt_dlcaller_id
3542  lt_dlcaller_register ()  lt_dlcaller_register ()
3543  {  {
3544    static int last_caller_id = -1;    static lt_dlcaller_id last_caller_id = 0;
3545    int result;    int result;
3546    
3547    LT_DLMUTEX_LOCK ();    LT_DLMUTEX_LOCK ();
# Line 3548  lt_dlcaller_register () Line 3551  lt_dlcaller_register ()
3551    return result;    return result;
3552  }  }
3553    
 #define N_ELEMENTS(a)   (sizeof(a) / sizeof(*(a)))  
   
3554  lt_ptr  lt_ptr
3555  lt_dlcaller_set_data (key, handle, data)  lt_dlcaller_set_data (key, handle, data)
3556       lt_dlcaller_id key;       lt_dlcaller_id key;
# Line 3565  lt_dlcaller_set_data (key, handle, data) Line 3566  lt_dlcaller_set_data (key, handle, data)
3566    LT_DLMUTEX_LOCK ();    LT_DLMUTEX_LOCK ();
3567    
3568    if (handle->caller_data)    if (handle->caller_data)
3569      n_elements = N_ELEMENTS (handle->caller_data);      while (handle->caller_data[n_elements].key)
3570          ++n_elements;
3571    
3572    for (i = 0; i < n_elements; ++i)    for (i = 0; i < n_elements; ++i)
3573      {      {
# Line 3577  lt_dlcaller_set_data (key, handle, data) Line 3579  lt_dlcaller_set_data (key, handle, data)
3579      }      }
3580    
3581    /* Ensure that there is enough room in this handle's caller_data    /* Ensure that there is enough room in this handle's caller_data
3582       array to accept a new element.  */       array to accept a new element (and an empty end marker).  */
3583    if (i == n_elements)    if (i == n_elements)
3584      {      {
3585        lt_caller_data *temp        lt_caller_data *temp
3586          = LT_DLREALLOC (lt_caller_data, handle->caller_data, 1+ n_elements);          = LT_DLREALLOC (lt_caller_data, handle->caller_data, 2+ n_elements);
3587    
3588        if (!temp)        if (!temp)
3589          {          {
# Line 3593  lt_dlcaller_set_data (key, handle, data) Line 3595  lt_dlcaller_set_data (key, handle, data)
3595    
3596        /* We only need this if we needed to allocate a new caller_data.  */        /* We only need this if we needed to allocate a new caller_data.  */
3597        handle->caller_data[i].key  = key;        handle->caller_data[i].key  = key;
3598          handle->caller_data[1+ i].key = 0;
3599      }      }
3600    
3601    handle->caller_data[i].data = data;    handle->caller_data[i].data = data;
# Line 3609  lt_dlcaller_get_data  (key, handle) Line 3612  lt_dlcaller_get_data  (key, handle)
3612       lt_dlhandle handle;       lt_dlhandle handle;
3613  {  {
3614    lt_ptr result = (lt_ptr) 0;    lt_ptr result = (lt_ptr) 0;
   int n_elements = 0;  
3615    
3616    /* This needs to be locked so that the caller data isn't updated by    /* This needs to be locked so that the caller data isn't updated by
3617       another thread part way through this function.  */       another thread part way through this function.  */
3618    LT_DLMUTEX_LOCK ();    LT_DLMUTEX_LOCK ();
3619    
   if (handle->caller_data)  
     n_elements = N_ELEMENTS (handle->caller_data);  
   
3620    /* Locate the index of the element with a matching KEY.  */    /* Locate the index of the element with a matching KEY.  */
3621    {    {
3622      int i;      int i;
3623      for (i = 0; i < n_elements; ++i)      for (i = 0; handle->caller_data[i].key; ++i)
3624        {        {
3625          if (handle->caller_data[i].key == key)          if (handle->caller_data[i].key == key)
3626            {            {

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26