From: Michael Vrable Date: Wed, 18 Nov 2009 03:19:13 +0000 (-0800) Subject: Clean up code using bluesky_string_from_gstring. X-Git-Url: http://git.vrable.net/?a=commitdiff_plain;h=f6cf25a6403fae7297c8d8913815dbd7a87f4f0b;p=bluesky.git Clean up code using bluesky_string_from_gstring. --- diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index 73c2157..21fd855 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -38,7 +38,7 @@ typedef struct { } BlueSkyRCStr; BlueSkyRCStr *bluesky_string_new(gpointer data, gsize len); -BlueSkyRCStr *bluesky_string_new_from_string(GString *s); +BlueSkyRCStr *bluesky_string_new_from_gstring(GString *s); void bluesky_string_ref(BlueSkyRCStr *string); void bluesky_string_unref(BlueSkyRCStr *string); BlueSkyRCStr *bluesky_string_dup(BlueSkyRCStr *string); diff --git a/bluesky/inode.c b/bluesky/inode.c index 5e91432..12cf7f7 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -198,9 +198,7 @@ void bluesky_inode_flush(BlueSkyFS *fs, BlueSkyInode *inode) { GString *buf = g_string_new(""); bluesky_serialize_inode(buf, inode); - - gsize len = buf->len; - BlueSkyRCStr *data = bluesky_string_new(g_string_free(buf, FALSE), len); + BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf); char key[64]; sprintf(key, "inode-%016"PRIx64, inode->inum); @@ -228,11 +226,10 @@ void bluesky_superblock_flush(BlueSkyFS *fs) { GString *buf = g_string_new(""); bluesky_serialize_superblock(buf, fs); + BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf); g_print("Syncing superblock...\n"); - gsize len = buf->len; - BlueSkyRCStr *data = bluesky_string_new(g_string_free(buf, FALSE), len); bluesky_store_put(fs->store, "superblock", data); } diff --git a/bluesky/s3store.c b/bluesky/s3store.c index 083023e..1a9e6b9 100644 --- a/bluesky/s3store.c +++ b/bluesky/s3store.c @@ -122,7 +122,7 @@ static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key) &handler, &info); BlueSkyRCStr *raw, *decrypted; - raw = bluesky_string_new_from_string(info.buf); + raw = bluesky_string_new_from_gstring(info.buf); decrypted = bluesky_crypt_decrypt(raw, store->encryption_key); bluesky_string_unref(raw); return decrypted; diff --git a/bluesky/util.c b/bluesky/util.c index 54c3c36..7f977a6 100644 --- a/bluesky/util.c +++ b/bluesky/util.c @@ -52,7 +52,7 @@ BlueSkyRCStr *bluesky_string_new(gpointer data, gsize len) } /* Create a new BlueSkyRCStr from a GString. The GString is destroyed. */ -BlueSkyRCStr *bluesky_string_new_from_string(GString *s) +BlueSkyRCStr *bluesky_string_new_from_gstring(GString *s) { gsize len = s->len; return bluesky_string_new(g_string_free(s, FALSE), len);