summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils/utils.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
commit6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (patch)
tree009fc492961e13860d2a4bc2de8caf2bbe2975e7 /src/libstrongswan/utils/utils.c
parentc83921a2b566aa9d55d8ccc7258f04fca6292ee6 (diff)
downloadvyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.tar.gz
vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.zip
Imported Upstream version 5.1.0
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r--src/libstrongswan/utils/utils.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c
index 2f38d8a93..30084cd81 100644
--- a/src/libstrongswan/utils/utils.c
+++ b/src/libstrongswan/utils/utils.c
@@ -48,19 +48,6 @@ ENUM(status_names, SUCCESS, NEED_MORE,
/**
* Described in header.
*/
-void *clalloc(void * pointer, size_t size)
-{
- void *data;
- data = malloc(size);
-
- memcpy(data, pointer, size);
-
- return (data);
-}
-
-/**
- * Described in header.
- */
void memxor(u_int8_t dst[], u_int8_t src[], size_t n)
{
int m, i;
@@ -115,7 +102,12 @@ void memwipe_noinline(void *ptr, size_t n)
void *memstr(const void *haystack, const char *needle, size_t n)
{
unsigned const char *pos = haystack;
- size_t l = strlen(needle);
+ size_t l;
+
+ if (!haystack || !needle || (l = strlen(needle)) == 0)
+ {
+ return NULL;
+ }
for (; n >= l; ++pos, --n)
{
if (memeq(pos, needle, l))
@@ -474,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;
}
/**