You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by da...@apache.org on 2007/08/04 16:58:04 UTC
svn commit: r562730 - /apr/apr-util/trunk/dbm/apr_dbm_ndbm.c
Author: davi
Date: Sat Aug 4 07:58:04 2007
New Revision: 562730
URL: http://svn.apache.org/viewvc?view=rev&rev=562730
Log:
Remove unused macro and explicit conversion (cast) from datum to apr_datum_t,
they might have different size, alignments, etc.
Modified:
apr/apr-util/trunk/dbm/apr_dbm_ndbm.c
Modified: apr/apr-util/trunk/dbm/apr_dbm_ndbm.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm_ndbm.c?view=diff&rev=562730&r1=562729&r2=562730
==============================================================================
--- apr/apr-util/trunk/dbm/apr_dbm_ndbm.c (original)
+++ apr/apr-util/trunk/dbm/apr_dbm_ndbm.c Sat Aug 4 07:58:04 2007
@@ -22,7 +22,7 @@
#include "apu.h"
-#if APU_HAVE_NDBM
+#if APU_HAVE_NDBM
#include "apr_dbm_private.h"
#include <ndbm.h>
@@ -30,10 +30,6 @@
#include <sys/stat.h>
#include <fcntl.h>
-/* this is used in a few places to define a noop "function". it is needed
- to stop "no effect" warnings from GCC. */
-#define NOOP_FUNCTION if (0) ; else
-
#define APR_DBM_DBMODE_RO O_RDONLY
#define APR_DBM_DBMODE_RW O_RDWR
#define APR_DBM_DBMODE_RWCREATE (O_RDWR|O_CREAT)
@@ -122,14 +118,17 @@
}
static apr_status_t vt_ndbm_fetch(apr_dbm_t *dbm, apr_datum_t key,
- apr_datum_t * pvalue)
+ apr_datum_t *pvalue)
{
- datum *ckey;
- datum rd;
+ datum kd, rd;
+
+ kd.dptr = key.dptr;
+ kd.dsize = key.dsize;
+
+ rd = dbm_fetch(dbm->file, kd);
- ckey = (datum*)&key;
- rd = dbm_fetch(dbm->file, *ckey);
- *pvalue = *(apr_datum_t*)&rd;
+ pvalue->dptr = rd.dptr;
+ pvalue->dsize = rd.dsize;
/* store the error info into DBM, and return a status code. Also, note
that *pvalue should have been cleared on error. */
@@ -139,59 +138,71 @@
static apr_status_t vt_ndbm_store(apr_dbm_t *dbm, apr_datum_t key,
apr_datum_t value)
{
- apr_status_t rv;
- datum *ckey;
- datum *cvalue;
-
- ckey = (datum*)&key;
- cvalue = (datum*)&value;
- rv = ndbm2s( dbm_store( dbm->file, *ckey, *cvalue, DBM_REPLACE));
+ int rc;
+ datum kd, vd;
+
+ kd.dptr = key.dptr;
+ kd.dsize = key.dsize;
+
+ vd.dptr = value.dptr;
+ vd.dsize = value.dsize;
+
+ rc = dbm_store(dbm->file, kd, vd, DBM_REPLACE);
/* store any error info into DBM, and return a status code. */
- return set_error(dbm, rv);
+ return set_error(dbm, ndbm2s(rc));
}
static apr_status_t vt_ndbm_del(apr_dbm_t *dbm, apr_datum_t key)
{
- apr_status_t rv;
- datum *ckey;
+ int rc;
+ datum kd;
+
+ kd.dptr = key.dptr;
+ kd.dsize = key.dsize;
- ckey = (datum*)&key;
- rv = ndbm2s( dbm_delete(dbm->file, *ckey));
+ rc = dbm_delete(dbm->file, kd);
/* store any error info into DBM, and return a status code. */
- return set_error(dbm, rv);
+ return set_error(dbm, ndbm2s(rc));
}
static int vt_ndbm_exists(apr_dbm_t *dbm, apr_datum_t key)
{
- datum *ckey = (datum *)&key;
- datum value;
+ datum kd, rd;
- value = dbm_fetch( dbm->file, *ckey);
+ kd.dptr = key.dptr;
+ kd.dsize = key.dsize;
- return value.dptr != NULL;
+ rd = dbm_fetch(dbm->file, kd);
+
+ return rd.dptr != NULL;
}
-static apr_status_t vt_ndbm_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey)
+static apr_status_t vt_ndbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey)
{
datum rd;
rd = dbm_firstkey(dbm->file);
- *pkey = *(apr_datum_t*)&rd;
+
+ pkey->dptr = rd.dptr;
+ pkey->dsize = rd.dsize;
/* store any error info into DBM, and return a status code. */
return set_error(dbm, APR_SUCCESS);
}
-static apr_status_t vt_ndbm_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey)
+static apr_status_t vt_ndbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
{
- datum *ckey;
- datum rd;
+ datum kd, rd;
+
+ kd.dptr = pkey->dptr;
+ kd.dsize = pkey->dsize;
- ckey = (datum*)pkey;
rd = dbm_nextkey(dbm->file);
- *pkey = *(apr_datum_t*)&rd;
+
+ pkey->dptr = rd.dptr;
+ pkey->dsize = rd.dsize;
/* store any error info into DBM, and return a status code. */
return set_error(dbm, APR_SUCCESS);
@@ -209,10 +220,8 @@
*used2 = NULL;
}
-
APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = {
"ndbm",
-
vt_ndbm_open,
vt_ndbm_close,
vt_ndbm_fetch,
@@ -224,4 +233,5 @@
vt_ndbm_freedatum,
vt_ndbm_usednames
};
+
#endif /* APU_HAVE_NDBM */