From: Alexander Larsson Date: Fri, 2 Oct 2009 07:48:35 +0000 (+0200) Subject: xdgmime - support cache files with minor version 2 X-Git-Tag: 2.22.2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c27df1feeea1d6ab8b927285cecc4ac34db8b06;p=platform%2Fupstream%2Fglib.git xdgmime - support cache files with minor version 2 --- diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c index 5bdac5b..0f2d83a 100644 --- a/gio/xdgmime/xdgmimecache.c +++ b/gio/xdgmime/xdgmimecache.c @@ -73,11 +73,13 @@ #endif #define MAJOR_VERSION 1 -#define MINOR_VERSION 1 +#define MINOR_VERSION_MIN 1 +#define MINOR_VERSION_MAX 2 struct _XdgMimeCache { int ref_count; + int minor; size_t size; char *buffer; @@ -116,6 +118,7 @@ _xdg_mime_cache_new_from_file (const char *file_name) int fd = -1; struct stat st; char *buffer = NULL; + int minor; /* Open the file and map it into memory */ fd = open (file_name, O_RDONLY|_O_BINARY, 0); @@ -131,9 +134,11 @@ _xdg_mime_cache_new_from_file (const char *file_name) if (buffer == MAP_FAILED) goto done; + minor = GET_UINT16 (buffer, 2); /* Verify version */ if (GET_UINT16 (buffer, 0) != MAJOR_VERSION || - GET_UINT16 (buffer, 2) != MINOR_VERSION) + (minor < MINOR_VERSION_MIN || + minor > MINOR_VERSION_MAX)) { munmap (buffer, st.st_size); @@ -141,6 +146,7 @@ _xdg_mime_cache_new_from_file (const char *file_name) } cache = (XdgMimeCache *) malloc (sizeof (XdgMimeCache)); + cache->minor = minor; cache->ref_count = 1; cache->buffer = buffer; cache->size = st.st_size;