refcnt.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*------------------------------------------------------------------------
  2. * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
  3. *
  4. * This file is part of the ZBar Bar Code Reader.
  5. *
  6. * The ZBar Bar Code Reader is free software; you can redistribute it
  7. * and/or modify it under the terms of the GNU Lesser Public License as
  8. * published by the Free Software Foundation; either version 2.1 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * The ZBar Bar Code Reader is distributed in the hope that it will be
  12. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  13. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser Public License
  17. * along with the ZBar Bar Code Reader; if not, write to the Free
  18. * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301 USA
  20. *
  21. * http://sourceforge.net/projects/zbar
  22. *------------------------------------------------------------------------*/
  23. #include "refcnt.h"
  24. #ifdef HAVE_LIBPTHREAD
  25. pthread_once_t initialized = PTHREAD_ONCE_INIT;
  26. pthread_mutex_t _zbar_reflock;
  27. static void initialize (void)
  28. {
  29. pthread_mutex_init(&_zbar_reflock, NULL);
  30. }
  31. void _zbar_refcnt_init ()
  32. {
  33. pthread_once(&initialized, initialize);
  34. }
  35. #else
  36. void _zbar_refcnt_init ()
  37. {
  38. }
  39. #endif