physfs.c
changeset 272 470430943851
parent 242 3143cfd544a6
child 314 a156f6155e3c
equal deleted inserted replaced
271:4ab1c1277b04 272:470430943851
   109 static ErrMsg *findErrorForCurrentThread(void)
   109 static ErrMsg *findErrorForCurrentThread(void)
   110 {
   110 {
   111     ErrMsg *i;
   111     ErrMsg *i;
   112     PHYSFS_uint64 tid;
   112     PHYSFS_uint64 tid;
   113 
   113 
   114     if (initialized)
   114     if (errorLock != NULL)
   115         __PHYSFS_platformGrabMutex(errorLock);
   115         __PHYSFS_platformGrabMutex(errorLock);
   116 
   116 
   117     if (errorMessages != NULL)
   117     if (errorMessages != NULL)
   118     {
   118     {
   119         tid = __PHYSFS_platformGetThreadID();
   119         tid = __PHYSFS_platformGetThreadID();
   120 
   120 
   121         for (i = errorMessages; i != NULL; i = i->next)
   121         for (i = errorMessages; i != NULL; i = i->next)
   122         {
   122         {
   123             if (i->tid == tid)
   123             if (i->tid == tid)
   124             {
   124             {
   125                 __PHYSFS_platformReleaseMutex(errorLock);
   125                 if (errorLock != NULL)
       
   126                     __PHYSFS_platformReleaseMutex(errorLock);
   126                 return(i);
   127                 return(i);
   127             } /* if */
   128             } /* if */
   128         } /* for */
   129         } /* for */
   129     } /* if */
   130     } /* if */
   130 
   131 
   131     if (initialized)
   132     if (errorLock != NULL)
   132         __PHYSFS_platformReleaseMutex(errorLock);
   133         __PHYSFS_platformReleaseMutex(errorLock);
   133 
   134 
   134     return(NULL);   /* no error available. */
   135     return(NULL);   /* no error available. */
   135 } /* findErrorForCurrentThread */
   136 } /* findErrorForCurrentThread */
   136 
   137 
   151             return;   /* uhh...? */
   152             return;   /* uhh...? */
   152 
   153 
   153         memset((void *) err, '\0', sizeof (ErrMsg));
   154         memset((void *) err, '\0', sizeof (ErrMsg));
   154         err->tid = __PHYSFS_platformGetThreadID();
   155         err->tid = __PHYSFS_platformGetThreadID();
   155 
   156 
   156         __PHYSFS_platformGrabMutex(errorLock);
   157         if (errorLock != NULL)
       
   158             __PHYSFS_platformGrabMutex(errorLock);
       
   159 
   157         err->next = errorMessages;
   160         err->next = errorMessages;
   158         errorMessages = err;
   161         errorMessages = err;
   159         __PHYSFS_platformReleaseMutex(errorLock);
   162 
       
   163         if (errorLock != NULL)
       
   164             __PHYSFS_platformReleaseMutex(errorLock);
   160     } /* if */
   165     } /* if */
   161 
   166 
   162     err->errorAvailable = 1;
   167     err->errorAvailable = 1;
   163     strncpy(err->errorString, str, sizeof (err->errorString));
   168     strncpy(err->errorString, str, sizeof (err->errorString));
   164     err->errorString[sizeof (err->errorString) - 1] = '\0';
   169     err->errorString[sizeof (err->errorString) - 1] = '\0';
   186     for (i = errorMessages; i != NULL; i = next)
   191     for (i = errorMessages; i != NULL; i = next)
   187     {
   192     {
   188         next = i->next;
   193         next = i->next;
   189         free(i);
   194         free(i);
   190     } /* for */
   195     } /* for */
       
   196 
       
   197     errorMessages = NULL;
   191 } /* freeErrorMessages */
   198 } /* freeErrorMessages */
   192 
   199 
   193 
   200 
   194 void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
   201 void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
   195 {
   202 {