Work to unify the cloud segment writing with other cache management.
[bluesky.git] / bluesky / util.c
index c4bac19..f899420 100644 (file)
@@ -53,17 +53,6 @@ gboolean bluesky_inode_is_ready(BlueSkyInode *inode)
 
 /**** Reference-counted strings. ****/
 
-void bluesky_mmap_unref(BlueSkyMmap *mmap)
-{
-    if (mmap == NULL)
-        return;
-
-    if (g_atomic_int_dec_and_test(&mmap->refcount)) {
-        munmap((void *)mmap->addr, mmap->len);
-        g_free(mmap);
-    }
-}
-
 /* Create and return a new reference-counted string.  The reference count is
  * initially one.  The newly-returned string takes ownership of the memory
  * pointed at by data, and will call g_free on it when the reference count
@@ -89,6 +78,8 @@ BlueSkyRCStr *bluesky_string_new_from_gstring(GString *s)
 BlueSkyRCStr *bluesky_string_new_from_mmap(BlueSkyMmap *mmap,
                                            int offset, gsize len)
 {
+    g_assert(offset + len < mmap->len);
+
     BlueSkyRCStr *string = g_new(BlueSkyRCStr, 1);
     string->mmap = mmap;
     g_atomic_int_inc(&mmap->refcount);