svn commit: samba r19423 - in branches/SAMBA_4_0/source/lib/tdb: common include

tridge at samba.org tridge at samba.org
Fri Oct 20 08:06:15 GMT 2006


Author: tridge
Date: 2006-10-20 08:06:14 +0000 (Fri, 20 Oct 2006)
New Revision: 19423

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19423

Log:

merge some tdb changes from SAMBA_3_0 to SAMBA_4_0

this is in preparation of a merge in the other direction

Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/io.c
   branches/SAMBA_4_0/source/lib/tdb/common/open.c
   branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
   branches/SAMBA_4_0/source/lib/tdb/common/transaction.c
   branches/SAMBA_4_0/source/lib/tdb/include/tdb.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/io.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/io.c	2006-10-20 07:44:09 UTC (rev 19422)
+++ branches/SAMBA_4_0/source/lib/tdb/common/io.c	2006-10-20 08:06:14 UTC (rev 19423)
@@ -102,7 +102,7 @@
 /* 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;
@@ -282,7 +282,8 @@
 	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;

Modified: branches/SAMBA_4_0/source/lib/tdb/common/open.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/open.c	2006-10-20 07:44:09 UTC (rev 19422)
+++ branches/SAMBA_4_0/source/lib/tdb/common/open.c	2006-10-20 08:06:14 UTC (rev 19423)
@@ -54,7 +54,7 @@
 
 	/* 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 */
@@ -140,7 +140,7 @@
 	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;
@@ -263,7 +263,8 @@
 	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, TDB_DEBUG_ERROR, "tdb_open_ex: "
 			 "failed to allocate lock structure for %s\n",

Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2006-10-20 07:44:09 UTC (rev 19422)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2006-10-20 08:06:14 UTC (rev 19423)
@@ -423,3 +423,8 @@
 	tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum);
 	return seqnum;
 }
+
+int tdb_hash_size(struct tdb_context *tdb)
+{
+	return tdb->header.hash_size;
+}

Modified: branches/SAMBA_4_0/source/lib/tdb/common/transaction.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/transaction.c	2006-10-20 07:44:09 UTC (rev 19422)
+++ branches/SAMBA_4_0/source/lib/tdb/common/transaction.c	2006-10-20 08:06:14 UTC (rev 19423)
@@ -258,7 +258,8 @@
 	     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 @@
 	}
 
 	/* 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 @@
 	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 @@
 		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 @@
 
 	/* 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 = (u32 *)
+		calloc(tdb->header.hash_size+1, sizeof(u32));
 	if (tdb->transaction->hash_heads == NULL) {
 		tdb->ecode = TDB_ERR_OOM;
 		goto fail;
@@ -684,7 +687,7 @@
 		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;
@@ -966,7 +969,7 @@
 
 	recovery_eof = rec.key_len;
 
-	data = malloc(rec.data_len);
+	data = (unsigned char *)malloc(rec.data_len);
 	if (data == NULL) {
 		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n"));		
 		tdb->ecode = TDB_ERR_OOM;

Modified: branches/SAMBA_4_0/source/lib/tdb/include/tdb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/include/tdb.h	2006-10-20 07:44:09 UTC (rev 19422)
+++ branches/SAMBA_4_0/source/lib/tdb/include/tdb.h	2006-10-20 08:06:14 UTC (rev 19423)
@@ -123,6 +123,7 @@
 int tdb_transaction_cancel(struct tdb_context *tdb);
 int tdb_transaction_recover(struct tdb_context *tdb);
 int tdb_get_seqnum(struct tdb_context *tdb);
+int tdb_hash_size(struct tdb_context *tdb);
 
 /* Low level locking functions: use with care */
 int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);



More information about the samba-cvs mailing list