}
return 0;
}
+
+/**
+ * Copy blocks from a container into another one. Blocks present in
+ * both @a src and @a dest are replaced in @a dest.
+ *
+ * @param dest Destination of copy operation
+ * @param src Source of copy operation
+ *
+ * @return Zero on success, non-zero error core on error.
+ */
+int fres_container_copy(struct fres_container *dest,
+ const struct fres_container *src)
+{
+ enum fres_block_type type;
+ int ret;
+
+ for (type=0; type<FRES_NUM_BLOCKS; type++) {
+ const struct fres_block *sb = &src->blocks[type];
+ struct fres_block *db = &dest->blocks[type];
+
+ if (sb->state != FRES_BLOCK_EMPTY) {
+ fres_container_del_block(dest, type);
+ ret = fres_block_duplicate(db, sb, type);
+ if (ret) {
+ return ret;
+ }
+ }
+ }
+ return 0;
+}
int fres_container_merge(struct fres_container *dest,
const struct fres_container *src);
+int fres_container_copy(struct fres_container *dest,
+ const struct fres_container *src);
+
#ifdef __cplusplus
} /* extern "C"*/
#endif