diff --git a/include/odfs/alloc.h b/include/odfs/alloc.h index cdf372c..ea14c74 100644 --- a/include/odfs/alloc.h +++ b/include/odfs/alloc.h @@ -27,11 +27,17 @@ static inline void *odfs_malloc(size_t size) { if (size == 0) size = 1; +#ifdef __AROS__ + return AllocVec((IPTR)size, MEMF_PUBLIC); +#else + if (sizeof(size_t) > sizeof(ULONG) && size > (size_t)(ULONG)-1) + return NULL; #if ODFS_AMIGA_OS4 return AllocVecTags((ULONG)size, AVT_Type, MEMF_SHARED, TAG_END); #else return AllocVec((ULONG)size, MEMF_PUBLIC); #endif +#endif } static inline void *odfs_calloc(size_t count, size_t size) @@ -45,6 +51,11 @@ static inline void *odfs_calloc(size_t count, size_t size) if (total == 0) total = 1; +#ifdef __AROS__ + return AllocVec((IPTR)total, MEMF_PUBLIC | MEMF_CLEAR); +#else + if (sizeof(size_t) > sizeof(ULONG) && total > (size_t)(ULONG)-1) + return NULL; #if ODFS_AMIGA_OS4 return AllocVecTags((ULONG)total, AVT_Type, MEMF_SHARED, @@ -53,6 +64,7 @@ static inline void *odfs_calloc(size_t count, size_t size) #else return AllocVec((ULONG)total, MEMF_PUBLIC | MEMF_CLEAR); #endif +#endif } static inline void odfs_free(void *ptr) diff --git a/include/odfs/config.h b/include/odfs/config.h index 27d652f..def5c8c 100644 --- a/include/odfs/config.h +++ b/include/odfs/config.h @@ -9,35 +9,23 @@ /* * Build profiles: - * ODFS_PROFILE_FULL — all features enabled (default) - * ODFS_PROFILE_ROM — minimal ROM-capable subset + * default — all features enabled + * ODFS_PROFILE_ROM — minimal ROM-capable subset * - * Set exactly one profile, or configure individual flags below. + * Configure individual flags below or override from command line + * (-DODFS_FEATURE_xxx=0). */ -#if !defined(ODFS_PROFILE_FULL) && !defined(ODFS_PROFILE_ROM) -#define ODFS_PROFILE_FULL -#endif - /* ---------- backend feature flags ---------- */ -/* All flags can be overridden from command line (-DODFS_FEATURE_xxx=0) */ #ifndef ODFS_FEATURE_ISO9660 #define ODFS_FEATURE_ISO9660 1 #endif #ifndef ODFS_FEATURE_ROCK_RIDGE - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_ROCK_RIDGE 1 - #else - #define ODFS_FEATURE_ROCK_RIDGE 1 - #endif + #define ODFS_FEATURE_ROCK_RIDGE 1 #endif #ifndef ODFS_FEATURE_JOLIET - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_JOLIET 1 - #else - #define ODFS_FEATURE_JOLIET 1 - #endif + #define ODFS_FEATURE_JOLIET 1 #endif #ifndef ODFS_FEATURE_HIGH_SIERRA #ifdef ODFS_PROFILE_ROM @@ -47,11 +35,7 @@ #endif #endif #ifndef ODFS_FEATURE_MULTISESSION - #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_MULTISESSION 1 - #else - #define ODFS_FEATURE_MULTISESSION 1 - #endif + #define ODFS_FEATURE_MULTISESSION 1 #endif #ifndef ODFS_FEATURE_UDF #ifdef ODFS_PROFILE_ROM @@ -90,9 +74,6 @@ #define ODFS_FEATURE_CACHE_RETAIN 1 #endif -#ifndef ODFS_FEATURE_CACHE_BLOCK - #define ODFS_FEATURE_CACHE_BLOCK 1 -#endif #ifndef ODFS_FEATURE_CACHE_META #ifdef ODFS_PROFILE_ROM #define ODFS_FEATURE_CACHE_META 0 @@ -112,23 +93,13 @@ /* ODFS_FEATURE_LOG can be overridden from command line (-DODFS_FEATURE_LOG=0) */ #ifndef ODFS_FEATURE_LOG -#ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_LOG 1 -#else - #define ODFS_FEATURE_LOG 1 -#endif + #define ODFS_FEATURE_LOG 1 #endif #ifdef ODFS_PROFILE_ROM - #define ODFS_FEATURE_LOG_SERIAL 1 - #define ODFS_FEATURE_LOG_KPRINTF 0 - #define ODFS_FEATURE_LOG_RINGBUF 0 - #define ODFS_LOG_MAX_LEVEL ODFS_LOG_WARN + #define ODFS_LOG_MAX_LEVEL ODFS_LOG_WARN #else - #define ODFS_FEATURE_LOG_SERIAL 1 - #define ODFS_FEATURE_LOG_KPRINTF 1 - #define ODFS_FEATURE_LOG_RINGBUF 1 - #define ODFS_LOG_MAX_LEVEL ODFS_LOG_TRACE + #define ODFS_LOG_MAX_LEVEL ODFS_LOG_TRACE #endif /* ---------- charset feature flags ---------- */ @@ -166,13 +137,4 @@ #define ODFS_PLATFORM_AMIGA 0 #endif -/* host builds for testing */ -#ifndef ODFS_PLATFORM_HOST - #if !ODFS_PLATFORM_AMIGA - #define ODFS_PLATFORM_HOST 1 - #else - #define ODFS_PLATFORM_HOST 0 - #endif -#endif - #endif /* ODFS_CONFIG_H */ diff --git a/include/odfs/media.h b/include/odfs/media.h index 8563c9a..e119c66 100644 --- a/include/odfs/media.h +++ b/include/odfs/media.h @@ -145,8 +145,7 @@ static inline void odfs_media_close(odfs_media_t *m) { if (!m || !m->ops || !m->ops->close) return; - if (m->ops->close) - m->ops->close(m->ctx); + m->ops->close(m->ctx); } /* host-side: open an image file as media */ diff --git a/include/odfs/string.h b/include/odfs/string.h index a02433e..5926b62 100644 --- a/include/odfs/string.h +++ b/include/odfs/string.h @@ -60,9 +60,16 @@ static inline int odfs_strcasecmp(const char *a, const char *b) unsigned char cb; for (;;) { - ca = odfs_ascii_tolower((unsigned char)*a++); - cb = odfs_ascii_tolower((unsigned char)*b++); - if (ca != cb || ca == '\0') + ca = (unsigned char)*a++; + cb = (unsigned char)*b++; + if (ca == cb) { + if (ca == '\0') + return 0; + continue; + } + ca = odfs_ascii_tolower(ca); + cb = odfs_ascii_tolower(cb); + if (ca != cb) return (int)ca - (int)cb; } }