diff options
Diffstat (limited to 'misc/tools/osmocon/talloc.c')
-rw-r--r-- | misc/tools/osmocon/talloc.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/misc/tools/osmocon/talloc.c b/misc/tools/osmocon/talloc.c index c0072441d..6d99fe8a4 100644 --- a/misc/tools/osmocon/talloc.c +++ b/misc/tools/osmocon/talloc.c @@ -1,4 +1,4 @@ -/* +/* Samba Unix SMB/CIFS implementation. Samba trivial allocation library - new interface @@ -7,11 +7,11 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2006 - + ** NOTE! The following LGPL license applies to the talloc ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -71,7 +71,7 @@ #define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */ #define TALLOC_MAGIC_REFERENCE ((const char *)1) -/* by default we abort when given a bad pointer (such as when talloc_free() is called +/* by default we abort when given a bad pointer (such as when talloc_free() is called on a pointer that came from malloc() */ #ifndef TALLOC_ABORT #define TALLOC_ABORT(reason) abort() @@ -185,7 +185,7 @@ static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) { const char *pp = (const char *)ptr; struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); - if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { + if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { if (tc->flags & TALLOC_FLAG_FREE) { talloc_abort_double_free(); } else { @@ -330,7 +330,7 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent, return result; } -/* +/* Allocate a bit of memory as a child of an existing pointer */ static inline void *__talloc(const void *context, size_t size) @@ -423,7 +423,7 @@ void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)) } /* - increase the reference count on a piece of memory. + increase the reference count on a piece of memory. */ int talloc_increase_ref_count(const void *ptr) { @@ -446,7 +446,7 @@ static int talloc_reference_destructor(struct talloc_reference_handle *handle) } /* - more efficient way to add a name to a pointer - the name must point to a + more efficient way to add a name to a pointer - the name must point to a true string constant */ static inline void _talloc_set_name_const(const void *ptr, const char *name) @@ -476,8 +476,8 @@ static inline void *_talloc_named_const(const void *context, size_t size, const make a secondary reference to a pointer, hanging off the given context. the pointer remains valid until both the original caller and this given context are freed. - - the major use for this is when two different structures need to reference the + + the major use for this is when two different structures need to reference the same underlying data, and you want to be able to free the two instances separately, and in either order */ @@ -503,7 +503,7 @@ void *_talloc_reference(const void *context, const void *ptr) } -/* +/* internal talloc_free call */ static inline int _talloc_free(void *ptr) @@ -611,7 +611,7 @@ static inline int _talloc_free(void *ptr) return 0; } -/* +/* move a lump of memory from one talloc context to another return the ptr on success, or NULL if it could not be transferred. passing NULL as ptr will always return NULL with no side effects. @@ -640,7 +640,7 @@ void *_talloc_steal(const void *new_ctx, const void *ptr) if (tc->prev) tc->prev->next = tc->next; if (tc->next) tc->next->prev = tc->prev; } - + tc->parent = tc->next = tc->prev = NULL; return discard_const_p(void, ptr); } @@ -729,7 +729,7 @@ int talloc_unlink(const void *context, void *ptr) return -1; } } - + tc_p = talloc_chunk_from_ptr(ptr); if (tc_p->refs == NULL) { @@ -951,7 +951,7 @@ void talloc_free_children(void *ptr) } } -/* +/* Allocate a bit of memory as a child of an existing pointer */ void *_talloc(const void *context, size_t size) @@ -977,8 +977,8 @@ void *talloc_named_const(const void *context, size_t size, const char *name) return _talloc_named_const(context, size, name); } -/* - free a talloc pointer. This also frees all child pointers of this +/* + free a talloc pointer. This also frees all child pointers of this pointer recursively return 0 if the memory is actually freed, otherwise -1. The memory @@ -1064,9 +1064,9 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n new_ptr = realloc(tc, size + TC_HDR_SIZE); } #endif - if (unlikely(!new_ptr)) { - tc->flags &= ~TALLOC_FLAG_FREE; - return NULL; + if (unlikely(!new_ptr)) { + tc->flags &= ~TALLOC_FLAG_FREE; + return NULL; } tc = (struct talloc_chunk *)new_ptr; @@ -1230,14 +1230,14 @@ static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_ } if (depth == 0) { - fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", + fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", (max_depth < 0 ? "full " :""), name, (unsigned long)talloc_total_size(ptr), (unsigned long)talloc_total_blocks(ptr)); return; } - fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n", + fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n", depth*4, "", name, (unsigned long)talloc_total_size(ptr), @@ -1344,8 +1344,8 @@ void talloc_enable_leak_report_full(void) atexit(talloc_report_null_full); } -/* - talloc and zero memory. +/* + talloc and zero memory. */ void *_talloc_zero(const void *ctx, size_t size, const char *name) { @@ -1359,7 +1359,7 @@ void *_talloc_zero(const void *ctx, size_t size, const char *name) } /* - memdup with a talloc. + memdup with a talloc. */ void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name) { |