aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/utils/allocator.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-12-01 07:35:03 +0000
committerMartin Willi <martin@strongswan.org>2005-12-01 07:35:03 +0000
commitd45ec1dedfa06155c344f5cce0ac7b2ec331c825 (patch)
treede2a74ae64525e4d45c3178ab7d16484297ce1dd /Source/charon/utils/allocator.c
parent2ef11339c720d06215f44555de020ea5ebdfd641 (diff)
downloadstrongswan-d45ec1dedfa06155c344f5cce0ac7b2ec331c825.tar.bz2
strongswan-d45ec1dedfa06155c344f5cce0ac7b2ec331c825.tar.xz
- implemented sa_config
- uses identification - and host - untested - ts need further tuning
Diffstat (limited to 'Source/charon/utils/allocator.c')
-rw-r--r--Source/charon/utils/allocator.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/charon/utils/allocator.c b/Source/charon/utils/allocator.c
index 46194e85f..8c314a88a 100644
--- a/Source/charon/utils/allocator.c
+++ b/Source/charon/utils/allocator.c
@@ -264,6 +264,25 @@ static void * clone_bytes(allocator_t *allocator,void * to_clone, size_t bytes,
return new_space;
}
+
+/**
+ * Implementation of allocator_t.clone_chunk.
+ */
+static chunk_t clone_chunk(allocator_t *allocator, chunk_t chunk, char * file, int line)
+{
+ private_allocator_t *this = (private_allocator_t *) allocator;
+ chunk_t clone = CHUNK_INITIALIZER;
+
+ if (chunk.ptr && chunk.len > 0)
+ {
+ clone.ptr = this->allocate_special(this,chunk.len,file,line,TRUE);
+ clone.len = chunk.len;
+ memcpy(clone.ptr, chunk.ptr, chunk.len);
+ }
+
+ return clone;
+}
+
/**
* Implementation of allocator_t.allocator_report_memory_leaks.
*/
@@ -305,6 +324,7 @@ static private_allocator_t allocator = {
free_pointer: free_pointer,
reallocate: reallocate,
clone_bytes : clone_bytes,
+ clone_chunk : clone_chunk,
report_memory_leaks: allocator_report_memory_leaks},
allocations: NULL,
allocate_special : allocate_special,
@@ -356,6 +376,25 @@ void * allocator_clone_bytes(void * pointer, size_t size)
return (data);
}
+
+/**
+ * Described in header
+ */
+static chunk_t clone_chunk(chunk_t chunk)
+{
+ chunk_t clone = CHUNK_INITIALIZER;
+
+ if (chunk.ptr && chunk.len > 0)
+ {
+ clone.ptr = malloc(chunk.len);
+ if (clone.ptr == NULL) {exit(-1)};
+ clone.len = chunk.len;
+ memcpy(clone.ptr, chunk.ptr, chunk.len);
+ }
+
+ return clone;
+}
+
/*
* Described in header
*/