+/* Free most of the resources used by an inode structure, but do not free the
+ * inode itself. Can be used if the inode data will be reloaded from
+ * serialized form to clear out old information first. */
+void bluesky_inode_free_resources(BlueSkyInode *inode)
+{
+ switch (inode->type) {
+ case BLUESKY_REGULAR:
+ if (inode->blocks != NULL) {
+ for (int i = 0; i < inode->blocks->len; i++) {
+ BlueSkyBlock *b = &g_array_index(inode->blocks,
+ BlueSkyBlock, i);
+ if (b->type == BLUESKY_BLOCK_DIRTY) {
+ g_error("Deleting an inode with dirty file data!");
+ }
+ bluesky_cloudlog_unref(b->ref);
+ bluesky_string_unref(b->dirty);
+ }
+ g_array_unref(inode->blocks);
+ inode->blocks = NULL;
+ }
+ break;
+
+ case BLUESKY_DIRECTORY:
+ if (inode->dirhash != NULL)
+ g_hash_table_destroy(inode->dirhash);
+ inode->dirhash = NULL;
+ if (inode->dirhash_folded != NULL)
+ g_hash_table_destroy(inode->dirhash_folded);
+ inode->dirhash_folded = NULL;
+ if (inode->dirents != NULL)
+ g_sequence_free(inode->dirents);
+ inode->dirents = NULL;
+ break;
+
+ case BLUESKY_SYMLINK:
+ g_free(inode->symlink_contents);
+ inode->symlink_contents = NULL;
+ break;
+
+ default:
+ break;
+ }
+}
+