apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r562631 - /apr/apr-util/trunk/dbm/apr_dbm_sdbm.c
Date Sat, 04 Aug 2007 00:34:13 GMT
Author: davi
Date: Fri Aug  3 17:34:12 2007
New Revision: 562631

URL: http://svn.apache.org/viewvc?view=rev&rev=562631
Log:
Remove confuse boilerplate macros, they are not helpful at all.

Diffstat:

 apr_dbm_sdbm.c |  111 +++++++++++++++++++++------------------------------------
  1 file changed, 41 insertions(+), 70 deletions(-)


Modified:
    apr/apr-util/trunk/dbm/apr_dbm_sdbm.c

Modified: apr/apr-util/trunk/dbm/apr_dbm_sdbm.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbm/apr_dbm_sdbm.c?view=diff&rev=562631&r1=562630&r2=562631
==============================================================================
--- apr/apr-util/trunk/dbm/apr_dbm_sdbm.c (original)
+++ apr/apr-util/trunk/dbm/apr_dbm_sdbm.c Fri Aug  3 17:34:12 2007
@@ -24,35 +24,7 @@
 #if APU_HAVE_SDBM
 
 #include "apr_dbm_private.h"
-
 #include "apr_sdbm.h"
-#if APR_HAVE_STDLIB_H
-#include <stdlib.h>  /* For abort() */
-#endif
-
-/* 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 defaults for now; these will go away in a while */
-#define REGISTER_CLEANUP(dbm, pdatum) NOOP_FUNCTION
-#define SET_FILE(pdb, f) ((pdb)->file = (f))
-
-typedef apr_sdbm_t *real_file_t;
-
-typedef apr_sdbm_datum_t cvt_datum_t;
-#define CONVERT_DATUM(cvt, pinput) ((cvt).dptr = (pinput)->dptr, (cvt).dsize = (pinput)->dsize)
-
-typedef apr_sdbm_datum_t result_datum_t;
-#define RETURN_DATUM(poutput, rd) ((poutput)->dptr = (rd).dptr, (poutput)->dsize =
(rd).dsize)
-
-#define APR_DBM_CLOSE(f)        apr_sdbm_close(f)
-#define APR_DBM_FETCH(f, k, v)  apr_sdbm_fetch(f, &(v), (k))
-#define APR_DBM_STORE(f, k, v)  apr_sdbm_store(f, (k), (v), APR_SDBM_REPLACE)
-#define APR_DBM_DELETE(f, k)    apr_sdbm_delete(f, (k))
-#define APR_DBM_FIRSTKEY(f, k)  apr_sdbm_firstkey(f, &(k))
-#define APR_DBM_NEXTKEY(f, k, nk) apr_sdbm_nextkey(f, &(nk))
-#define APR_DBM_FREEDPTR(dptr)  NOOP_FUNCTION
 
 #define APR_DBM_DBMODE_RO       (APR_READ | APR_BUFFERED)
 #define APR_DBM_DBMODE_RW       (APR_READ | APR_WRITE)
@@ -86,7 +58,7 @@
                                  apr_int32_t mode, apr_fileperms_t perm,
                                  apr_pool_t *pool)
 {
-    real_file_t file;
+    apr_sdbm_t *file;
     int dbmode;
 
     *pdb = NULL;
@@ -120,7 +92,7 @@
     *pdb = apr_pcalloc(pool, sizeof(**pdb));
     (*pdb)->pool = pool;
     (*pdb)->type = &apr_dbm_type_sdbm;
-    SET_FILE(*pdb, file);
+    (*pdb)->file = file;
 
     /* ### register a cleanup to close the DBM? */
 
@@ -129,21 +101,22 @@
 
 static void vt_sdbm_close(apr_dbm_t *dbm)
 {
-    APR_DBM_CLOSE(dbm->file);
+    apr_sdbm_close(dbm->file);
 }
 
 static apr_status_t vt_sdbm_fetch(apr_dbm_t *dbm, apr_datum_t key,
-                                  apr_datum_t * pvalue)
+                                  apr_datum_t *pvalue)
 {
     apr_status_t rv;
-    cvt_datum_t ckey;
-    result_datum_t rd;
+    apr_sdbm_datum_t kd, rd;
+
+    kd.dptr = key.dptr;
+    kd.dsize = key.dsize;
 
-    CONVERT_DATUM(ckey, &key);
-    rv = APR_DBM_FETCH(dbm->file, ckey, rd);
-    RETURN_DATUM(pvalue, rd);
+    rv = apr_sdbm_fetch(dbm->file, &rd, kd);
 
-    REGISTER_CLEANUP(dbm, pvalue);
+    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. */
@@ -154,12 +127,15 @@
                                   apr_datum_t value)
 {
     apr_status_t rv;
-    cvt_datum_t ckey;
-    cvt_datum_t cvalue;
+    apr_sdbm_datum_t kd, vd;
+
+    kd.dptr = key.dptr;
+    kd.dsize = key.dsize;
+
+    vd.dptr = value.dptr;
+    vd.dsize = value.dsize;
 
-    CONVERT_DATUM(ckey, &key);
-    CONVERT_DATUM(cvalue, &value);
-    rv = APR_DBM_STORE(dbm->file, ckey, cvalue);
+    rv = apr_sdbm_store(dbm->file, kd, vd, APR_SDBM_REPLACE);
 
     /* store any error info into DBM, and return a status code. */
     return set_error(dbm, rv);
@@ -168,10 +144,12 @@
 static apr_status_t vt_sdbm_del(apr_dbm_t *dbm, apr_datum_t key)
 {
     apr_status_t rv;
-    cvt_datum_t ckey;
+    apr_sdbm_datum_t kd;
 
-    CONVERT_DATUM(ckey, &key);
-    rv = APR_DBM_DELETE(dbm->file, ckey);
+    kd.dptr = key.dptr;
+    kd.dsize = key.dsize;
+
+    rv = apr_sdbm_delete(dbm->file, kd);
 
     /* store any error info into DBM, and return a status code. */
     return set_error(dbm, rv);
@@ -180,47 +158,42 @@
 static int vt_sdbm_exists(apr_dbm_t *dbm, apr_datum_t key)
 {
     int exists;
-    apr_sdbm_datum_t ckey;
+    apr_sdbm_datum_t vd, kd;
 
-    CONVERT_DATUM(ckey, &key);
+    kd.dptr = key.dptr;
+    kd.dsize = key.dsize;
 
-    {
-        apr_sdbm_datum_t value;
-        if (apr_sdbm_fetch(dbm->file, &value, ckey) != APR_SUCCESS) {
-            exists = 0;
-        }
-        else
-            exists = value.dptr != NULL;
-    }
+    if (apr_sdbm_fetch(dbm->file, &vd, kd) != APR_SUCCESS)
+        exists = 0;
+    else
+        exists = vd.dptr != NULL;
 
     return exists;
 }
 
-static apr_status_t vt_sdbm_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey)
+static apr_status_t vt_sdbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey)
 {
     apr_status_t rv;
-    result_datum_t rd;
+    apr_sdbm_datum_t rd;
 
-    rv = APR_DBM_FIRSTKEY(dbm->file, rd);
-    RETURN_DATUM(pkey, rd);
+    rv = apr_sdbm_firstkey(dbm->file, &rd);
 
-    REGISTER_CLEANUP(dbm, pkey);
+    pkey->dptr = rd.dptr;
+    pkey->dsize = rd.dsize;
 
     /* store any error info into DBM, and return a status code. */
     return set_error(dbm, rv);
 }
 
-static apr_status_t vt_sdbm_nextkey(apr_dbm_t *dbm, apr_datum_t * pkey)
+static apr_status_t vt_sdbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
 {
     apr_status_t rv;
-    cvt_datum_t ckey;
-    result_datum_t rd;
+    apr_sdbm_datum_t rd;
 
-    CONVERT_DATUM(ckey, pkey);
-    rv = APR_DBM_NEXTKEY(dbm->file, ckey, rd);
-    RETURN_DATUM(pkey, rd);
+    rv = apr_sdbm_nextkey(dbm->file, &rd);
 
-    REGISTER_CLEANUP(dbm, pkey);
+    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);
@@ -228,7 +201,6 @@
 
 static void vt_sdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data)
 {
-    APR_DBM_FREEDPTR(data.dptr);
 }
 
 static void vt_sdbm_usednames(apr_pool_t *pool, const char *pathname,
@@ -249,7 +221,6 @@
 
 APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_sdbm = {
     "sdbm",
-
     vt_sdbm_open,
     vt_sdbm_close,
     vt_sdbm_fetch,



Mime
View raw message