X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=share%2Farray.c;h=590ac217efe5deec8a01f96af0088c660c68bd5d;hb=4483dfdacd29073b37a6429ca8e123c80deac75a;hp=4240025fb3d4a7753f99a3596e1e2ea7e8c529a9;hpb=36bb97ad64fa7b6d54dde257f2d3ab742252c5a5;p=neverball diff --git a/share/array.c b/share/array.c index 4240025..590ac21 100644 --- a/share/array.c +++ b/share/array.c @@ -1,3 +1,17 @@ +/* + * Copyright (C) 2003-2010 Neverball authors + * + * NEVERBALL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + #include #include @@ -79,3 +93,10 @@ int array_len(Array a) return a->elem_num; } + +void array_sort(Array a, int (*cmp)(const void *, const void *)) +{ + assert(a); + + qsort(a->data, a->elem_num, a->elem_len, cmp); +}