Fixed _xdg_mime_cache_list_mime_parents()

This commit is contained in:
Yevgen Muntyan 2007-01-07 22:26:53 -06:00
parent ecdd1a58f0
commit 39198279d1

View File

@ -907,9 +907,11 @@ char **
_xdg_mime_cache_list_mime_parents (const char *mime) _xdg_mime_cache_list_mime_parents (const char *mime)
{ {
int i, j, p; int i, j, p;
char *all_parents[128]; /* we'll stop at 128 */ char *all_parents[128]; /* we'll stop at 128 */
char **result; char **result;
mime = xdg_mime_unalias_mime_type (mime);
p = 0; p = 0;
for (i = 0; _xdg_mime_caches[i]; i++) for (i = 0; _xdg_mime_caches[i]; i++)
{ {
@ -920,15 +922,20 @@ _xdg_mime_cache_list_mime_parents (const char *mime)
for (j = 0; j < n_entries; j++) for (j = 0; j < n_entries; j++)
{ {
xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * i); xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j);
xdg_uint32_t parents_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * i + 4); xdg_uint32_t parents_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j + 4);
if (strcmp (cache->buffer + mimetype_offset, mime) == 0) if (strcmp (cache->buffer + mimetype_offset, mime) == 0)
{ {
int k;
xdg_uint32_t parent_mime_offset;
xdg_uint32_t n_parents = GET_UINT32 (cache->buffer, parents_offset); xdg_uint32_t n_parents = GET_UINT32 (cache->buffer, parents_offset);
for (j = 0; j < n_parents; j++) for (k = 0; k < n_parents; k++)
all_parents[p++] = cache->buffer + parents_offset + 4 + 4 * j; {
parent_mime_offset = GET_UINT32 (cache->buffer, parents_offset + 4 + 4 * k);
all_parents[p++] = cache->buffer + parent_mime_offset;
}
break; break;
} }
@ -941,4 +948,3 @@ _xdg_mime_cache_list_mime_parents (const char *mime)
return result; return result;
} }