summaryrefslogtreecommitdiff
path: root/source3/tdb
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/tdb
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/tdb')
-rw-r--r--source3/tdb/io.c7
-rw-r--r--source3/tdb/open.c7
-rw-r--r--source3/tdb/tdb.c5
-rw-r--r--source3/tdb/tdbback.c2
-rw-r--r--source3/tdb/tdbutil.c4
-rw-r--r--source3/tdb/transaction.c17
6 files changed, 24 insertions, 18 deletions
diff --git a/source3/tdb/io.c b/source3/tdb/io.c
index ac6f4cdf57..5d7edfefff 100644
--- a/source3/tdb/io.c
+++ b/source3/tdb/io.c
@@ -124,7 +124,7 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
/* Endian conversion: we only ever deal with 4 byte quantities */
void *tdb_convert(void *buf, u32 size)
{
- u32 i, *p = buf;
+ u32 i, *p = (u32 *)buf;
for (i = 0; i < size / 4; i++)
p[i] = TDB_BYTEREV(p[i]);
return buf;
@@ -304,7 +304,8 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
tdb->map_size += size;
if (tdb->flags & TDB_INTERNAL) {
- char *new_map_ptr = realloc(tdb->map_ptr, tdb->map_size);
+ char *new_map_ptr = (char *)realloc(tdb->map_ptr,
+ tdb->map_size);
if (!new_map_ptr) {
tdb->map_size -= size;
goto fail;
@@ -360,7 +361,7 @@ char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len)
len = 1;
}
- if (!(buf = malloc(len))) {
+ if (!(buf = (char *)malloc(len))) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_OOM;
TDB_LOG((tdb, 0,"tdb_alloc_read malloc failed len=%d (%s)\n",
diff --git a/source3/tdb/open.c b/source3/tdb/open.c
index cb4a9cd994..b53b4c9f5c 100644
--- a/source3/tdb/open.c
+++ b/source3/tdb/open.c
@@ -54,7 +54,7 @@ static int tdb_new_database(struct tdb_context *tdb, int hash_size)
/* We make it up in memory, then write it out if not internal */
size = sizeof(struct tdb_header) + (hash_size+1)*sizeof(tdb_off_t);
- if (!(newdb = calloc(size, 1)))
+ if (!(newdb = (struct tdb_header *)calloc(size, 1)))
return TDB_ERRCODE(TDB_ERR_OOM, -1);
/* Fill in the header */
@@ -139,7 +139,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
unsigned char *vp;
u32 vertest;
- if (!(tdb = calloc(1, sizeof *tdb))) {
+ if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
/* Can't log this */
errno = ENOMEM;
goto fail;
@@ -257,7 +257,8 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb->map_size = st.st_size;
tdb->device = st.st_dev;
tdb->inode = st.st_ino;
- tdb->locked = calloc(tdb->header.hash_size+1, sizeof(tdb->locked[0]));
+ tdb->locked = (struct tdb_lock_type *)calloc(tdb->header.hash_size+1,
+ sizeof(tdb->locked[0]));
if (!tdb->locked) {
TDB_LOG((tdb, 2, "tdb_open_ex: "
"failed to allocate lock structure for %s\n",
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 1fae6b6de1..524d404a50 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -355,9 +355,10 @@ int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf)
dbuf = tdb_fetch(tdb, key);
if (dbuf.dptr == NULL) {
- dbuf.dptr = malloc(new_dbuf.dsize);
+ dbuf.dptr = (char *)malloc(new_dbuf.dsize);
} else {
- dbuf.dptr = realloc(dbuf.dptr, dbuf.dsize + new_dbuf.dsize);
+ dbuf.dptr = (char *)realloc(dbuf.dptr,
+ dbuf.dsize + new_dbuf.dsize);
}
if (dbuf.dptr == NULL) {
diff --git a/source3/tdb/tdbback.c b/source3/tdb/tdbback.c
index c337924d6c..4698e6016b 100644
--- a/source3/tdb/tdbback.c
+++ b/source3/tdb/tdbback.c
@@ -63,7 +63,7 @@ char *add_suffix(const char *name, const char *suffix)
{
char *ret;
int len = strlen(name) + strlen(suffix) + 1;
- ret = malloc(len);
+ ret = (char *)malloc(len);
if (!ret) {
fprintf(stderr,"Out of memory!\n");
exit(1);
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index e13f7e3e67..b946f856aa 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -209,7 +209,7 @@ int tdb_store_int32_byblob(TDB_CONTEXT *tdb, const char *keystr, size_t len, int
int32 v_store;
SIVAL(&v_store,0,v);
- data.dptr = (void *)&v_store;
+ data.dptr = (char *)&v_store;
data.dsize = sizeof(int32);
return tdb_store(tdb, key, data, TDB_REPLACE);
@@ -269,7 +269,7 @@ BOOL tdb_store_uint32_byblob(TDB_CONTEXT *tdb, const char *keystr, size_t len, u
BOOL ret = True;
SIVAL(&v_store, 0, value);
- data.dptr = (void *)&v_store;
+ data.dptr = (char *)&v_store;
data.dsize = sizeof(uint32);
if (tdb_store(tdb, key, data, TDB_REPLACE) == -1)
diff --git a/source3/tdb/transaction.c b/source3/tdb/transaction.c
index aa54c4ae3c..b71728db5c 100644
--- a/source3/tdb/transaction.c
+++ b/source3/tdb/transaction.c
@@ -258,7 +258,8 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
off > tdb->transaction->old_map_size)) {
unsigned char *data = best_el->data;
el = best_el;
- el->data = realloc(el->data, el->length + len);
+ el->data = (unsigned char *)realloc(el->data,
+ el->length + len);
if (el->data == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
@@ -275,7 +276,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
}
/* add a new entry at the end of the list */
- el = malloc(sizeof(*el));
+ el = (struct tdb_transaction_el *)malloc(sizeof(*el));
if (el == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
@@ -285,7 +286,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
el->prev = tdb->transaction->elements_last;
el->offset = off;
el->length = len;
- el->data = malloc(len);
+ el->data = (unsigned char *)malloc(len);
if (el->data == NULL) {
free(el);
tdb->ecode = TDB_ERR_OOM;
@@ -411,7 +412,8 @@ int tdb_transaction_start(struct tdb_context *tdb)
return -1;
}
- tdb->transaction = calloc(sizeof(struct tdb_transaction), 1);
+ tdb->transaction = (struct tdb_transaction *)
+ calloc(sizeof(struct tdb_transaction), 1);
if (tdb->transaction == NULL) {
tdb->ecode = TDB_ERR_OOM;
return -1;
@@ -437,7 +439,8 @@ int tdb_transaction_start(struct tdb_context *tdb)
/* setup a copy of the hash table heads so the hash scan in
traverse can be fast */
- tdb->transaction->hash_heads = calloc(tdb->header.hash_size+1, sizeof(tdb_off_t));
+ tdb->transaction->hash_heads = (unsigned int *)
+ calloc(tdb->header.hash_size+1, sizeof(tdb_off_t));
if (tdb->transaction->hash_heads == NULL) {
tdb->ecode = TDB_ERR_OOM;
goto fail;
@@ -678,7 +681,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
return -1;
}
- data = malloc(recovery_size + sizeof(*rec));
+ data = (unsigned char *)malloc(recovery_size + sizeof(*rec));
if (data == NULL) {
tdb->ecode = TDB_ERR_OOM;
return -1;
@@ -960,7 +963,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
recovery_eof = rec.key_len;
- data = malloc(rec.data_len);
+ data = (unsigned char *)malloc(rec.data_len);
if (data == NULL) {
TDB_LOG((tdb, 0, "tdb_transaction_recover: failed to allocate recovery data\n"));
tdb->ecode = TDB_ERR_OOM;