Fix memory leak in video_output on Mac OS X (close #6267)
[vlc/solaris.git] / src / misc / threads.c
blobe3f2cb21b2eb1374915f71ee307ed0c775fcb3aa
1 /*****************************************************************************
2 * threads.c : threads implementation for the VideoLAN client
3 *****************************************************************************
4 * Copyright (C) 1999-2008 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Gildas Bazin <gbazin@netcourrier.com>
10 * Clément Sténac
11 * Rémi Denis-Courmont
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation; either version 2.1 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <assert.h>
35 /*** Global locks ***/
37 void vlc_global_mutex (unsigned n, bool acquire)
39 static vlc_mutex_t locks[] = {
40 VLC_STATIC_MUTEX,
41 VLC_STATIC_MUTEX,
42 VLC_STATIC_MUTEX,
43 VLC_STATIC_MUTEX,
44 VLC_STATIC_MUTEX,
46 static_assert (VLC_MAX_MUTEX == (sizeof (locks) / sizeof (locks[0])),
47 "Wrong number of global mutexes");
48 assert (n < (sizeof (locks) / sizeof (locks[0])));
50 vlc_mutex_t *lock = locks + n;
51 if (acquire)
52 vlc_mutex_lock (lock);
53 else
54 vlc_mutex_unlock (lock);