forked from AuroraMiddleware/gtk
Make repeated calls accumulate the results, don't call qsort() on empty
2004-12-09 Matthias Clasen <mclasen@redhat.com> * xdgmimealias.c (_xdg_mime_alias_read_from_file): * xdgmimeparent.c (_xdg_mime_parent_read_from_file): Make repeated calls accumulate the results, don't call qsort() on empty arrays. (#160838, Mariano Suárez-Alvarez)
This commit is contained in:
parent
fa136147ff
commit
94ab8fe8c0
@ -1,3 +1,10 @@
|
||||
2004-12-09 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* xdgmimealias.c (_xdg_mime_alias_read_from_file):
|
||||
* xdgmimeparent.c (_xdg_mime_parent_read_from_file): Make
|
||||
repeated calls accumulate the results, don't call qsort()
|
||||
on empty arrays. (#160838, Mariano Suárez-Alvarez)
|
||||
|
||||
2004-12-02 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* === Released 2.5.6 ===
|
||||
|
@ -128,8 +128,8 @@ _xdg_mime_alias_read_from_file (XdgAliasList *list,
|
||||
|
||||
/* FIXME: Not UTF-8 safe. Doesn't work if lines are greater than 255 chars.
|
||||
* Blah */
|
||||
alloc = 16;
|
||||
list->aliases = malloc (alloc * sizeof (XdgAlias));
|
||||
alloc = list->n_aliases + 16;
|
||||
list->aliases = realloc (list->aliases, alloc * sizeof (XdgAlias));
|
||||
while (fgets (line, 255, file) != NULL)
|
||||
{
|
||||
char *sep;
|
||||
@ -156,8 +156,9 @@ _xdg_mime_alias_read_from_file (XdgAliasList *list,
|
||||
|
||||
fclose (file);
|
||||
|
||||
qsort (list->aliases, list->n_aliases,
|
||||
sizeof (XdgAlias), alias_entry_cmp);
|
||||
if (list->n_aliases > 1)
|
||||
qsort (list->aliases, list->n_aliases,
|
||||
sizeof (XdgAlias), alias_entry_cmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,8 +134,8 @@ _xdg_mime_parent_read_from_file (XdgParentList *list,
|
||||
|
||||
/* FIXME: Not UTF-8 safe. Doesn't work if lines are greater than 255 chars.
|
||||
* Blah */
|
||||
alloc = 16;
|
||||
list->parents = malloc (alloc * sizeof (XdgMimeParents));
|
||||
alloc = list->n_mimes + 16;
|
||||
list->parents = realloc (list->parents, alloc * sizeof (XdgMimeParents));
|
||||
while (fgets (line, 255, file) != NULL)
|
||||
{
|
||||
char *sep;
|
||||
@ -191,8 +191,9 @@ _xdg_mime_parent_read_from_file (XdgParentList *list,
|
||||
|
||||
fclose (file);
|
||||
|
||||
qsort (list->parents, list->n_mimes,
|
||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||
if (list->n_mimes > 1)
|
||||
qsort (list->parents, list->n_mimes,
|
||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user