api changes
[oweals/gnunet.git] / src / datacache / datacache.c
index 7c92f77378a914f0163b278d45f6b9f5355fe6e0..936031b91f07555715cc01d414624e92f8076fb3 100644 (file)
@@ -109,8 +109,7 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
   struct GNUNET_DATACACHE_Handle *h = cls;
 
 #if DEBUG_DATACACHE
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Content under key `%s' discarded\n",
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n",
        GNUNET_h2s (key));
 #endif
   GNUNET_assert (h->utilization >= size);
@@ -139,7 +138,7 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
   char *name;
 
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg, section, "QUOTA", &quota))
+      GNUNET_CONFIGURATION_get_value_size (cfg, section, "QUOTA", &quota))
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
          _("No `%s' specified for `%s' in configuration!\n"), "QUOTA", section);
@@ -162,10 +161,17 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
     ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name, quota / 1024,     /* 8 bit per entry in DB, expect 1k entries */
                                                      5);
   }
-  else
+  if (NULL == ret->filter)
   {
     ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */
   }
+  if (NULL == ret->filter)
+  {
+    GNUNET_free (name);
+    GNUNET_free (ret->bloom_name);
+    GNUNET_free (ret);
+    return NULL;
+  }
   ret->stats = GNUNET_STATISTICS_create ("datacache", cfg);
   ret->section = GNUNET_strdup (section);
   ret->env.cfg = cfg;
@@ -243,8 +249,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
     return GNUNET_SYSERR;
   }
 #if DEBUG_DATACACHE
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Stored data under key `%s' in cache\n",
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
        GNUNET_h2s (key));
 #endif
   GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
@@ -276,8 +281,7 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
   GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
                             GNUNET_NO);
 #if DEBUG_DATACACHE
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Processing request for key `%s'\n",
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n",
        GNUNET_h2s (key));
 #endif
   if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
@@ -287,9 +291,8 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
                               ("# requests filtered by bloom filter"), 1,
                               GNUNET_NO);
 #if DEBUG_DATACACHE
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Bloomfilter filters request for key `%s'\n",
-        GNUNET_h2s (key));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n",
+         GNUNET_h2s (key));
 #endif
     return 0;                   /* can not be present */
   }