Mercurial > hg > dmlib
changeset 602:c1a5652e473d
Sanitize resource preloading function a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 12 Apr 2013 09:34:21 +0300 |
parents | 588998ccc07a |
children | 36b544eb6f4b |
files | dmres.c dmres.h |
diffstat | 2 files changed, 28 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/dmres.c Fri Apr 12 08:21:49 2013 +0300 +++ b/dmres.c Fri Apr 12 09:34:21 2013 +0300 @@ -572,12 +572,12 @@ #ifdef DM_USE_PACKFS if (handle->lib->flags & DRF_USE_PACK) handle->fops = &dfPackFileOps; -#ifdef DM_USE_STDIO +# ifdef DM_USE_STDIO else handle->fops = &dfStdioFileOps; -#else +# else handle->fops = &dfPackFileOps; -#endif +# endif #else handle->fops = NULL; @@ -591,47 +591,44 @@ int ret = DMERR_INIT_FAIL; // Check if we want to preload raw data? - if (((handle->flags & DMF_PRELOAD_RAW) || - (handle->lib->flags & DRF_PRELOAD_ALL)) && - (handle->flags & DMF_LOADED_RAW) == 0 && - handle->fops->preload != NULL) + if ((handle->flags & DMF_PRELOAD_RAW) || + (handle->lib->flags & DRF_PRELOAD_ALL)) { - ret = handle->fops->preload(handle); - if (ret == DMERR_OK) + if (handle->flags & DMF_LOADED_RAW) + ret = DMERR_OK; + else + if (handle->fops->preload != NULL) { - handle->flags |= DMF_LOADED_RAW; + ret = handle->fops->preload(handle); + if (ret == DMERR_OK) + handle->flags |= DMF_LOADED_RAW; } } else { if (handle->fops->fopen != NULL) ret = handle->fops->fopen(handle); - else - if (handle->fops->preload != NULL) - { - ret = handle->fops->preload(handle); - if (ret == DMERR_OK) - { - handle->flags |= DMF_LOADED_RAW; - } - } } // Check if resource data is to be preloaded - if (((handle->flags & DMF_PRELOAD_RES) || (handle->lib->flags & DRF_PRELOAD_RES)) && - (handle->flags & DMF_LOADED_RES) == 0 && - handle->rops != NULL && - handle->rops->load != NULL) + if ((handle->flags & DMF_PRELOAD_RES) || (handle->lib->flags & DRF_PRELOAD_RES)) { - ret = handle->rops->load(handle); - if (ret == DMERR_OK) + if (handle->flags & DMF_LOADED_RES) + ret = DMERR_OK; + else + if (handle->rops != NULL && + handle->rops->load != NULL) { - // Okay, mark as loaded - handle->flags |= DMF_LOADED_RES; + ret = handle->rops->load(handle); + if (ret == DMERR_OK) + { + // Okay, mark as loaded + handle->flags |= DMF_LOADED_RES; - // Check if we can purge the raw data now - if ((handle->flags & DMF_PERSIST) == 0) - dmres_purge_raw_data(handle); + // Check if we can purge the raw data now + if ((handle->flags & DMF_PERSIST) == 0) + dmres_purge_raw_data(handle); + } } }