Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: cbootimage.c

Issue 6469010: Factor out the context specific functions into their own file. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cbootimage.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « GNUmakefile ('k') | context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cbootimage.c
diff --git a/cbootimage.c b/cbootimage.c
index 798ce0487aa7160b250fd6eda83556e255135b45..1792749c6e3a75066b0f86a466379a701a861bfb 100644
--- a/cbootimage.c
+++ b/cbootimage.c
@@ -30,6 +30,7 @@
#include "data_layout.h"
#include "parse.h"
#include "set.h"
+#include "context.h"
/*
* Global data
@@ -43,64 +44,6 @@ static int help_only = 0; // Only print help & exit
*/
int main(int argc, char *argv[]);
-static int
-query_alloc(build_image_context *context,
- nvbct_lib_id size_id,
- u_int8_t **dst)
-{
- u_int32_t size;
-
- /* Note: 3rd argument not used in this particular query. */
- if (context->bctlib.get_value(size_id,
- &size, context->bct) != 0)
- return -ENODATA;
- *dst = malloc(size);
-
- if (*dst == NULL)
- return -ENOMEM;
-
- memset(*dst, 0, size);
-
- return 0;
-}
-
-static void
-cleanup_context(build_image_context *context)
-{
- destroy_block_list(context->memory);
- destroy_addon_list(context->addon_tbl.addon_item_list);
- free(context->bct);
-}
-
-static int
-init_context(build_image_context *context)
-{
- int e = 0;
-
- /* Set defaults */
- context->memory = new_block_list();
- context->journal_blk = 1; /* Default to 1st block */
-
- /* Allocate space for the bct.
- * Note that this is different from the old code which pointed directly
- * into a memory image.
- */
- e = query_alloc(context, nvbct_lib_id_bct_size, &(context->bct));
- if (e != 0)
- goto fail;
-
- context_set_value(context, token_page_size, 2048);
- context_set_value(context, token_redundancy, 1);
- context_set_value(context, token_version, 1);
-
- return 0;
-
- fail:
- cleanup_context(context);
-
- return e;
-}
-
int
write_image_file(build_image_context *context)
{
« no previous file with comments | « GNUmakefile ('k') | context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698