Procházet zdrojové kódy

Make all interface members static.

Stefano Cossu před 2 roky
rodič
revize
1b57cb41ef
2 změnil soubory, kde provedl 42 přidání a 39 odebrání
  1. 17 15
      src/store_htable.c
  2. 25 24
      src/store_mdb.c

+ 17 - 15
src/store_htable.c

@@ -151,12 +151,12 @@ htiter_next_key (HTIterator *it);
  * @param[in] id Graph identifier. This may or may not be set. The store does
  *  not use this value internally, and does not check for duplicates.
  *
- * @param[in] size Initial size of the store (in number of triples). It may be
- *  0.
+ * @param[in] size Initial size of the store (in number of triples to
+ * preallocate). It may be 0.
  *
  * @return New graph store.
  */
-void *
+static void *
 htstore_new (const char *id, size_t size)
 {
     HTStore *ht;
@@ -177,7 +177,7 @@ htstore_new (const char *id, size_t size)
 
 
 #if 0
-LSUP_rc
+static LSUP_rc
 htstore_copy_contents (HTStore *dest, const HTStore *src)
 {
     size_t i = 0;
@@ -198,7 +198,7 @@ htstore_copy_contents (HTStore *dest, const HTStore *src)
 #endif
 
 
-void
+static void
 htstore_free (void *h)
 {
     HTStore *store = h;
@@ -208,7 +208,7 @@ htstore_free (void *h)
 }
 
 
-size_t
+static size_t
 htstore_size (const void *h)
 {
     const HTStore *store = h;
@@ -216,7 +216,7 @@ htstore_size (const void *h)
 }
 
 
-LSUP_rc
+static LSUP_rc
 htstore_add_term (void *h, const LSUP_Buffer *sterm)
 {
     HTStore *store = h;
@@ -237,7 +237,7 @@ htstore_add_term (void *h, const LSUP_Buffer *sterm)
 }
 
 
-void *
+static void *
 htstore_add_init (void *h, const LSUP_Buffer *_unused)
 {
     (void) _unused;
@@ -250,7 +250,7 @@ htstore_add_init (void *h, const LSUP_Buffer *_unused)
 }
 
 
-LSUP_rc
+static LSUP_rc
 htstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
 {
     HTIterator *it = h;
@@ -271,7 +271,7 @@ htstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
 }
 
 
-LSUP_rc
+static LSUP_rc
 htstore_add_done (void *h)
 {
     free (h);
@@ -279,7 +279,7 @@ htstore_add_done (void *h)
 }
 
 
-void *
+static void *
 htstore_lookup (
         void *h,
         const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
@@ -348,7 +348,7 @@ htstore_lookup (
 }
 
 
-LSUP_rc
+static LSUP_rc
 htstore_remove(
         void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
         const LSUP_Buffer *so,  const LSUP_Buffer *_unused, size_t *ct_p)
@@ -383,7 +383,7 @@ finally:
 }
 
 
-LSUP_rc
+static LSUP_rc
 htiter_next_key (HTIterator *it)
 {
     if (UNLIKELY (!it)) return LSUP_VALUE_ERR;
@@ -412,7 +412,7 @@ htiter_next_key (HTIterator *it)
 }
 
 
-LSUP_rc
+static LSUP_rc
 htiter_next (void *h, LSUP_BufferTriple *sspo, LSUP_Buffer **_unused)
 {
     (void) _unused;
@@ -447,7 +447,9 @@ const LSUP_StoreInt htstore_int = {
 };
 
 
-/* * * Statics * * */
+/*
+ * Other statics.
+ */
 
 inline static LSUP_rc
 tkey_to_strp (

+ 25 - 24
src/store_mdb.c

@@ -1,5 +1,3 @@
-#include <ftw.h>
-
 #include "store_mdb.h"
 
 /**
@@ -11,12 +9,12 @@
  * Memory map size.
  */
 #if (defined DEBUG || defined TESTING)
-    #define DEFAULT_MAPSIZE 1<<24 // 16Mb (limit for Valgrind)
+#define DEFAULT_MAPSIZE 1<<24 // 16Mb (limit for Valgrind)
 #elif !(defined __LP64__ || defined __LLP64__) || \
         defined _WIN32 && !defined _WIN64
-    #define DEFAULT_MAPSIZE 1<<31 // 2Gb (limit for 32-bit systems)
+#define DEFAULT_MAPSIZE 1<<31 // 2Gb (limit for 32-bit systems)
 #else
-    #define DEFAULT_MAPSIZE 1UL<<40 // 1Tb
+#define DEFAULT_MAPSIZE 1UL<<40 // 1Tb
 #endif
 
 #define ENV_DIR_MODE 0750
@@ -201,7 +199,7 @@ inline static LSUP_rc lookup_3bound(MDBIterator *it, size_t *ct);
  * Store interface.
  */
 
-LSUP_NSMap *
+static LSUP_NSMap *
 mdbstore_nsm_get (void *h)
 {
     MDBStore *store = h;
@@ -241,7 +239,7 @@ finally:
 }
 
 
-LSUP_rc
+static LSUP_rc
 mdbstore_nsm_put (void *h, const LSUP_NSMap *nsm)
 {
     MDBStore *store = h;
@@ -332,7 +330,7 @@ mdbstore_path_from_id (const char *id)
  * and checking that it's a writable directory. If the path is not specified
  * in the LSUP_MDB_STORE_URN environment variable, a default directory is used.
  */
-LSUP_rc
+static LSUP_rc
 mdbstore_setup (const char *id, bool clear)
 {
     const char *path = mdbstore_path_from_id (id);
@@ -380,7 +378,7 @@ mdbstore_setup (const char *id, bool clear)
  *   it is not necessary to modify this, unless one is operating under memory
  *   and disk constraints. The default map size is 1Tb.
  */
-void *
+static void *
 mdbstore_new (const char *id, size_t _unused)
 {
     (void) _unused;
@@ -436,7 +434,7 @@ fail:
 }
 
 
-void
+static void
 mdbstore_free (void *h)
 {
     MDBStore *store = h;
@@ -451,7 +449,8 @@ mdbstore_free (void *h)
 }
 
 
-char *mdbstore_id (const void *h)
+static char *
+mdbstore_id (const void *h)
 {
     const MDBStore *store = h;
     const char *path;
@@ -461,7 +460,7 @@ char *mdbstore_id (const void *h)
 }
 
 
-LSUP_rc
+static LSUP_rc
 mdbstore_stat (const MDBStore *store, MDB_stat *stat)
 {
     if (!(store->state & LSSTORE_OPEN)) return 0;
@@ -477,7 +476,7 @@ mdbstore_stat (const MDBStore *store, MDB_stat *stat)
 }
 
 
-size_t
+static size_t
 mdbstore_size (const void *h)
 {
     const MDBStore *store = h;
@@ -490,7 +489,7 @@ mdbstore_size (const void *h)
 }
 
 
-void *
+static void *
 mdbstore_add_init (void *h, const LSUP_Buffer *sc)
 {
     MDBStore *store = h;
@@ -544,7 +543,7 @@ mdbstore_add_init (void *h, const LSUP_Buffer *sc)
  * #mdbstore_add_abort or #mdbstore_add_done. FIXME
  *
  */
-LSUP_rc
+static LSUP_rc
 mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
 {
     if (UNLIKELY (!h)) return LSUP_VALUE_ERR;
@@ -603,7 +602,7 @@ mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
 }
 
 
-LSUP_rc
+static LSUP_rc
 mdbstore_add_done (void *h)
 {
     MDBIterator *it = h;
@@ -622,7 +621,7 @@ mdbstore_add_done (void *h)
 }
 
 
-void
+static void
 mdbstore_add_abort (void *h)
 {
     MDBIterator *it = h;
@@ -634,8 +633,9 @@ mdbstore_add_abort (void *h)
 }
 
 
+#if 0
 /* TODO deprecate. Use low-level instead and abstract at graph level. */
-LSUP_rc
+static LSUP_rc
 mdbstore_add (
         void *h, const LSUP_Buffer *sc,
         const LSUP_BufferTriple strp[], const size_t ct, size_t *inserted)
@@ -655,6 +655,7 @@ mdbstore_add (
 
     return mdbstore_add_done (it);
 }
+#endif
 
 
 static LSUP_rc
@@ -682,7 +683,7 @@ key_to_sterm (MDBIterator *it, const LSUP_Key key, LSUP_Buffer *sterm)
 }
 
 
-void *
+static void *
 mdbstore_lookup (
         void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
         const LSUP_Buffer *so, const LSUP_Buffer *sc, size_t *ct)
@@ -780,7 +781,7 @@ mdbstore_lookup (
  * ckset is filled with an array of contexts that the triple appears
  * in, if not NULL.
  */
-inline static LSUP_rc
+static LSUP_rc
 mdbiter_next_key (MDBIterator *it)
 {
     if (UNLIKELY (!it)) return LSUP_VALUE_ERR;
@@ -872,7 +873,7 @@ mdbiter_next_key (MDBIterator *it)
 }
 
 
-LSUP_rc
+static LSUP_rc
 mdbiter_next (
         void *h, LSUP_BufferTriple *sspo, LSUP_Buffer **ctx_p)
 {
@@ -911,7 +912,7 @@ mdbiter_next (
 }
 
 
-void
+static void
 mdbiter_free (void *h)
 {
     MDBIterator *it = h;
@@ -926,7 +927,7 @@ mdbiter_free (void *h)
 }
 
 
-LSUP_rc
+static LSUP_rc
 mdbstore_remove(
         void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
         const LSUP_Buffer *so, const LSUP_Buffer *sc, size_t *ct)
@@ -1016,7 +1017,7 @@ fail:
 }
 
 
-int
+static int
 mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
 {
     int db_rc, rc;