mirror of
https://github.com/samba-team/samba.git
synced 2025-12-16 00:23:52 +03:00
r20193: - let talloc_parent_chunk() handle a NULL pointer
- use talloc_parent_chunk() in talloc_parent_name()
- add prototype of talloc_parent_name()
metze
(This used to be commit 85fc18f047)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
f0eaae956f
commit
bfbf6d546b
@@ -164,8 +164,15 @@ do { \
|
|||||||
*/
|
*/
|
||||||
static struct talloc_chunk *talloc_parent_chunk(const void *ptr)
|
static struct talloc_chunk *talloc_parent_chunk(const void *ptr)
|
||||||
{
|
{
|
||||||
struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
|
struct talloc_chunk *tc;
|
||||||
|
|
||||||
|
if (unlikely(ptr == NULL)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tc = talloc_chunk_from_ptr(ptr);
|
||||||
while (tc->prev) tc=tc->prev;
|
while (tc->prev) tc=tc->prev;
|
||||||
|
|
||||||
return tc->parent;
|
return tc->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,23 +185,12 @@ void *talloc_parent(const void *ptr)
|
|||||||
/*
|
/*
|
||||||
find parents name
|
find parents name
|
||||||
*/
|
*/
|
||||||
const char *talloc_parent_name(const void *context)
|
const char *talloc_parent_name(const void *ptr)
|
||||||
{
|
{
|
||||||
struct talloc_chunk *tc;
|
struct talloc_chunk *tc = talloc_parent_chunk(ptr);
|
||||||
|
return tc? tc->name : NULL;
|
||||||
if (unlikely(context == NULL)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tc = talloc_chunk_from_ptr(context);
|
|
||||||
while (tc && tc->prev) tc = tc->prev;
|
|
||||||
if (tc) {
|
|
||||||
tc = tc->parent;
|
|
||||||
}
|
|
||||||
return tc->name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allocate a bit of memory as a child of an existing pointer
|
Allocate a bit of memory as a child of an existing pointer
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ void *talloc_named_const(const void *context, size_t size, const char *name);
|
|||||||
const char *talloc_get_name(const void *ptr);
|
const char *talloc_get_name(const void *ptr);
|
||||||
void *talloc_check_name(const void *ptr, const char *name);
|
void *talloc_check_name(const void *ptr, const char *name);
|
||||||
void *talloc_parent(const void *ptr);
|
void *talloc_parent(const void *ptr);
|
||||||
|
const char *talloc_parent_name(const void *ptr);
|
||||||
void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
|
void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
|
||||||
int talloc_free(void *ptr);
|
int talloc_free(void *ptr);
|
||||||
void talloc_free_children(void *ptr);
|
void talloc_free_children(void *ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user