Update of /cvsroot/alsa/alsa-lib/src/control In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31652/src/control
Modified Files: hcontrol.c Log Message: Stephen Cook <[EMAIL PROTECTED]>: - removed the function-in-function for qsort. replaced with a static function with a static variable. now protected with pthread mutex. Index: hcontrol.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/control/hcontrol.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- hcontrol.c 13 Oct 2003 12:06:46 -0000 1.32 +++ hcontrol.c 26 Jan 2004 15:54:10 -0000 1.33 @@ -48,6 +48,7 @@ #include <string.h> #include <fcntl.h> #include <sys/ioctl.h> +#include <pthread.h> #ifndef DOC_HIDDEN #define __USE_GNU #endif @@ -409,17 +410,26 @@ return 0; } +static snd_hctl_t *compare_hctl; +static int hctl_compare(const void *a, const void *b) { + return compare_hctl->compare(*(const snd_hctl_elem_t * const *) a, + *(const snd_hctl_elem_t * const *) b); +} + static void snd_hctl_sort(snd_hctl_t *hctl) { unsigned int k; - int compar(const void *a, const void *b) { - return hctl->compare(*(const snd_hctl_elem_t * const *) a, - *(const snd_hctl_elem_t * const *) b); - } + static pthread_mutex_t sync_lock = PTHREAD_MUTEX_INITIALIZER; + assert(hctl); assert(hctl->compare); INIT_LIST_HEAD(&hctl->elems); - qsort(hctl->pelems, hctl->count, sizeof(*hctl->pelems), compar); + + pthread_mutex_lock(&sync_lock); + compare_hctl = hctl; + qsort(hctl->pelems, hctl->count, sizeof(*hctl->pelems), hctl_compare); + pthread_mutex_unlock(&sync_lock); + for (k = 0; k < hctl->count; k++) list_add_tail(&hctl->pelems[k]->list, &hctl->elems); } ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog