platform/beos.cpp
changeset 745 df04959950eb
parent 657 dad3b5c307a9
child 788 3df4f1b61339
equal deleted inserted replaced
743:8afd4cb34040 745:df04959950eb
    70             BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
    70             BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
    71             rc = entry.GetPath(&path);
    71             rc = entry.GetPath(&path);
    72             BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
    72             BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
    73             const char *str = path.Path();
    73             const char *str = path.Path();
    74             BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL);  /* ?! */
    74             BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL);  /* ?! */
    75             char *retval = (char *) malloc(strlen(str) + 1);
    75             char *retval = (char *) allocator.Malloc(strlen(str) + 1);
    76             BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    76             BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    77             strcpy(retval, str);
    77             strcpy(retval, str);
    78             return(retval);
    78             return(retval);
    79         } /* if */
    79         } /* if */
    80     } /* while */
    80     } /* while */
   133                         {
   133                         {
   134                             char *mntpnt = getMountPoint(name);
   134                             char *mntpnt = getMountPoint(name);
   135                             if (mntpnt != NULL)
   135                             if (mntpnt != NULL)
   136                             {
   136                             {
   137                                 callback(data, mntpnt);
   137                                 callback(data, mntpnt);
   138                                 free(mntpnt);  /* !!! FIXME: lose this malloc! */
   138                                 allocator.Free(mntpnt);  /* !!! FIXME: lose this malloc! */
   139                             } /* if */
   139                             } /* if */
   140                         } /* if */
   140                         } /* if */
   141                     } /* if */
   141                     } /* if */
   142                 } /* if */
   142                 } /* if */
   143             } /* if */
   143             } /* if */
   176     assert(rc == B_OK);
   176     assert(rc == B_OK);
   177     rc = path.GetParent(&path); /* chop filename, keep directory. */
   177     rc = path.GetParent(&path); /* chop filename, keep directory. */
   178     assert(rc == B_OK);
   178     assert(rc == B_OK);
   179     const char *str = path.Path();
   179     const char *str = path.Path();
   180     assert(str != NULL);
   180     assert(str != NULL);
   181     char *retval = (char *) malloc(strlen(str) + 1);
   181     char *retval = (char *) allocator.Malloc(strlen(str) + 1);
   182     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   182     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   183     strcpy(retval, str);
   183     strcpy(retval, str);
   184     return(retval);
   184     return(retval);
   185 } /* __PHYSFS_platformCalcBaseDir */
   185 } /* __PHYSFS_platformCalcBaseDir */
   186 
   186 
   208         *(leaf++) = '\0';
   208         *(leaf++) = '\0';
   209 
   209 
   210     BPath normalized(str, leaf, true);  /* force normalization of path. */
   210     BPath normalized(str, leaf, true);  /* force normalization of path. */
   211     const char *resolved_path = normalized.Path();
   211     const char *resolved_path = normalized.Path();
   212     BAIL_IF_MACRO(resolved_path == NULL, ERR_NO_SUCH_FILE, NULL);
   212     BAIL_IF_MACRO(resolved_path == NULL, ERR_NO_SUCH_FILE, NULL);
   213     char *retval = (char *) malloc(strlen(resolved_path) + 1);
   213     char *retval = (char *) allocator.Malloc(strlen(resolved_path) + 1);
   214     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   214     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   215     strcpy(retval, resolved_path);
   215     strcpy(retval, resolved_path);
   216     return(retval);
   216     return(retval);
   217 } /* __PHYSFS_platformRealPath */
   217 } /* __PHYSFS_platformRealPath */
   218 
   218 
   219 
   219 
   220 void *__PHYSFS_platformCreateMutex(void)
   220 void *__PHYSFS_platformCreateMutex(void)
   221 {
   221 {
   222     sem_id *retval = (sem_id *) malloc(sizeof (sem_id));
   222     sem_id *retval = (sem_id *) allocator.Malloc(sizeof (sem_id));
   223     sem_id rc;
   223     sem_id rc;
   224 
   224 
   225     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   225     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   226     rc = create_sem(1, "PhysicsFS semaphore");
   226     rc = create_sem(1, "PhysicsFS semaphore");
   227     if (rc < B_OK)
   227     if (rc < B_OK)
   228     {
   228     {
   229         free(retval);
   229         allocator.Free(retval);
   230         BAIL_MACRO(strerror(rc), NULL);
   230         BAIL_MACRO(strerror(rc), NULL);
   231     } // if
   231     } // if
   232 
   232 
   233     *retval = rc;
   233     *retval = rc;
   234     return(retval);
   234     return(retval);
   236 
   236 
   237 
   237 
   238 void __PHYSFS_platformDestroyMutex(void *mutex)
   238 void __PHYSFS_platformDestroyMutex(void *mutex)
   239 {
   239 {
   240     delete_sem( *((sem_id *) mutex) );
   240     delete_sem( *((sem_id *) mutex) );
   241     free(mutex);
   241     allocator.Free(mutex);
   242 } /* __PHYSFS_platformDestroyMutex */
   242 } /* __PHYSFS_platformDestroyMutex */
   243 
   243 
   244 
   244 
   245 int __PHYSFS_platformGrabMutex(void *mutex)
   245 int __PHYSFS_platformGrabMutex(void *mutex)
   246 {
   246 {