aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-05-08 15:07:09 +0200
committerMartin Willi <martin@revosec.ch>2013-06-11 15:54:27 +0200
commit3160b92adb396c5445b2f5b16b496c6fb5cec5b0 (patch)
tree3db5b348f9bce1d84950ac38e3f4dcb85b3495ae /src/libstrongswan/utils/utils.c
parent37a60cad3cfbf9ce98b6c76564f419fe884a1d71 (diff)
downloadstrongswan-3160b92adb396c5445b2f5b16b496c6fb5cec5b0.tar.bz2
strongswan-3160b92adb396c5445b2f5b16b496c6fb5cec5b0.tar.xz
utils: ref_get() returns the new value of the reference counter
This allows us to use ref_get() for getting unique values.
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r--src/libstrongswan/utils/utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c
index aa59f4a4d..30084cd81 100644
--- a/src/libstrongswan/utils/utils.c
+++ b/src/libstrongswan/utils/utils.c
@@ -466,11 +466,15 @@ static pthread_mutex_t ref_mutex = PTHREAD_MUTEX_INITIALIZER;
/**
* Increase refcount
*/
-void ref_get(refcount_t *ref)
+refcount_t ref_get(refcount_t *ref)
{
+ refcount_t current;
+
pthread_mutex_lock(&ref_mutex);
- (*ref)++;
+ current = ++(*ref);
pthread_mutex_unlock(&ref_mutex);
+
+ return current;
}
/**