]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_private.h
fix a memory leak when freeing locks
[netatalk.git] / libatalk / adouble / ad_private.h
1 /*
2  * $Id: ad_private.h,v 1.3 2002-08-16 08:07:57 didg Exp $
3  */
4
5 #ifndef LIBATALK_ADOUBLE_AD_PRIVATE_H
6 #define LIBATALK_ADOUBLE_AD_PRIVATE_H 1
7
8 #include <atalk/adouble.h>
9
10 #ifndef MAP_FAILED
11 #define MAP_FAILED ((void *) -1)
12 #endif /* ! MAP_FAILED */
13
14 #ifndef __inline__
15 #define __inline__
16 #endif /* ! __inline__ */
17
18 /* this is so that we can keep lists of fds referencing the same file
19  * around. that way, we can honor locks created by the same process
20  * with the same file. */
21 #ifdef USE_FLOCK_LOCKS
22 #define adf_lock_init(a)
23 #define adf_lock_free(a)
24 #else /* USE_FLOCK_LOCKS */
25
26 #define adf_lock_init(a) do { \
27         (a)->adf_lockmax = (a)->adf_lockcount = 0; \
28         (a)->adf_lock = NULL; \
29 } while (0)
30
31 #define adf_lock_free(a) do { \
32     int i;\
33         if (!(a)->adf_lock) \
34                 break; \
35         for (i = 0; i < (a)->adf_lockcount; i++) {\
36             adf_lock_t *lock = (a)->adf_lock + i;\
37             if (--(*lock->refcount) < 1)free(lock->refcount); \
38         }\
39         free((a)->adf_lock); \
40         adf_lock_init(a); \
41 } while (0)
42 #endif /* USE_FLOCK_LOCKS */
43
44 #endif /* libatalk/adouble/ad_private.h */