]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_lock.h
fce: FCE version 2 with new event types and new config options
[netatalk.git] / libatalk / adouble / ad_lock.h
index 8e7860d2a2c3c3e372ef2c305ba50f04064f352b..2d15da908bbab2d0673edebcfbb1f258750263f3 100644 (file)
@@ -7,9 +7,23 @@
  * around. that way, we can honor locks created by the same process
  * with the same file. */
 
-#define adf_lock_free(a)                                      \
-    do {                                                      \
-        ;                                                     \
+#define adf_lock_init(a) do {   \
+        (a)->adf_lockmax = 0;   \
+        (a)->adf_lockcount = 0; \
+        (a)->adf_lock = NULL;   \
+    } while (0)
+
+#define adf_lock_free(a) do {                                 \
+        int i;                                                \
+        if (!(a)->adf_lock)                                   \
+            break;                                            \
+        for (i = 0; i < (a)->adf_lockcount; i++) {            \
+            adf_lock_t *lock = (a)->adf_lock + i;             \
+            if (--(*lock->refcount) < 1)                      \
+                free(lock->refcount);                         \
+        }                                                     \
+        free((a)->adf_lock);                                  \
+        adf_lock_init(a);                                     \
     } while (0)
 
 #endif /* libatalk/adouble/ad_private.h */