summaryrefslogtreecommitdiff
path: root/source3/lib/talloc.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-07-30 10:42:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:25 -0500
commit5a5deade6e4634aad561139f39337c9a960c0b80 (patch)
tree9907286b6e90ac4dfbbdf1194c08c99cd07701e7 /source3/lib/talloc.c
parent2c6030415e0b1f421ea6e85fe6ffe7389ee7a941 (diff)
downloadsamba-5a5deade6e4634aad561139f39337c9a960c0b80.tar.gz
samba-5a5deade6e4634aad561139f39337c9a960c0b80.tar.bz2
samba-5a5deade6e4634aad561139f39337c9a960c0b80.zip
r17315: Make talloc and tdb C++-warning-free. Would this also be interesting in talloc
and tdb "upstream"? Volker (This used to be commit 68c43191c8aa4faa9801e0ab084a216ceaf4379d)
Diffstat (limited to 'source3/lib/talloc.c')
-rw-r--r--source3/lib/talloc.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index 9d82441137..0e223e8bbe 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -111,7 +111,7 @@ struct talloc_chunk {
/* panic if we get a bad magic value */
static struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
{
- const char *pp = ptr;
+ const char *pp = (const char *)ptr;
struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
if ((tc->flags & ~0xF) != TALLOC_MAGIC) {
TALLOC_ABORT("Bad talloc magic value - unknown value");
@@ -181,7 +181,7 @@ void *_talloc(const void *context, size_t size)
return NULL;
}
- tc = malloc(TC_HDR_SIZE+size);
+ tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
if (tc == NULL) return NULL;
tc->size = size;
@@ -234,7 +234,8 @@ void talloc_increase_ref_count(const void *ptr)
*/
static int talloc_reference_destructor(void *ptr)
{
- struct talloc_reference_handle *handle = ptr;
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)ptr;
struct talloc_chunk *tc1 = talloc_chunk_from_ptr(ptr);
struct talloc_chunk *tc2 = talloc_chunk_from_ptr(handle->ptr);
if (tc1->destructor != (talloc_destructor_t)-1) {
@@ -261,7 +262,8 @@ void *talloc_reference(const void *context, const void *ptr)
if (ptr == NULL) return NULL;
tc = talloc_chunk_from_ptr(ptr);
- handle = talloc_named_const(context, sizeof(*handle), TALLOC_MAGIC_REFERENCE);
+ handle = (struct talloc_reference_handle *)talloc_named_const(
+ context, sizeof(*handle), TALLOC_MAGIC_REFERENCE);
if (handle == NULL) return NULL;
@@ -543,7 +545,7 @@ int talloc_free(void *ptr)
if (tc->refs) {
int is_child;
struct talloc_reference_handle *handle = tc->refs;
- is_child = talloc_is_parent(handle, handle->ptr);
+ is_child = talloc_is_parent(handle, (const char *)handle->ptr);
talloc_reference_destructor(tc->refs);
if (is_child) {
return talloc_free(ptr);
@@ -639,13 +641,13 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
return NULL;
}
- tc = new_ptr;
+ tc = (struct talloc_chunk *)new_ptr;
tc->flags &= ~TALLOC_FLAG_FREE;
if (tc->parent) {
- tc->parent->child = new_ptr;
+ tc->parent->child = (struct talloc_chunk *)new_ptr;
}
if (tc->child) {
- tc->child->parent = new_ptr;
+ tc->child->parent = (struct talloc_chunk *)new_ptr;
}
if (tc->prev) {
@@ -805,7 +807,8 @@ void talloc_report_depth(const void *ptr, FILE *f, int depth)
for (c=tc->child;c;c=c->next) {
if (c->name == TALLOC_MAGIC_REFERENCE) {
- struct talloc_reference_handle *handle = TC_PTR_FROM_CHUNK(c);
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
const char *name2 = talloc_get_name(handle->ptr);
fprintf(f, "%*sreference to: %s\n", depth*4, "", name2);
} else {
@@ -927,7 +930,8 @@ static void talloc_report_depth_str(const void *ptr, char **pps, ssize_t *plen,
for (c=tc->child;c;c=c->next) {
if (c->name == TALLOC_MAGIC_REFERENCE) {
- struct talloc_reference_handle *handle = TC_PTR_FROM_CHUNK(c);
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
const char *name2 = talloc_get_name(handle->ptr);
sprintf_append(NULL, pps, plen, pbuflen,
@@ -1033,7 +1037,7 @@ char *talloc_strdup(const void *t, const char *p)
if (!p) {
return NULL;
}
- ret = talloc_memdup(t, p, strlen(p) + 1);
+ ret = (char *)talloc_memdup(t, p, strlen(p) + 1);
if (ret) {
talloc_set_name_const(ret, ret);
}
@@ -1074,7 +1078,7 @@ char *talloc_strndup(const void *t, const char *p, size_t n)
for (len=0; len<n && p[len]; len++) ;
- ret = _talloc(t, len + 1);
+ ret = (char *)_talloc(t, len + 1);
if (!ret) { return NULL; }
memcpy(ret, p, len);
ret[len] = 0;
@@ -1106,7 +1110,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
return NULL;
}
- ret = _talloc(t, len+1);
+ ret = (char *)_talloc(t, len+1);
if (ret) {
VA_COPY(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);