From ec6fb5d1ce75fa3746f473727f2533e629bdb136 Mon Sep 17 00:00:00 2001 From: "C. Davis" Date: Wed, 8 Aug 2012 20:16:05 -0700 Subject: regedit: Initialize hexedit buf with data if available. Reviewed-by: Andreas Schneider Reviewed-by: Michael Adam --- source3/utils/regedit_hexedit.c | 6 +++++- source3/utils/regedit_hexedit.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/regedit_hexedit.c b/source3/utils/regedit_hexedit.c index c86feaddb0..42eee8f78a 100644 --- a/source3/utils/regedit_hexedit.c +++ b/source3/utils/regedit_hexedit.c @@ -23,7 +23,7 @@ static int hexedit_free(struct hexedit *buf) } struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, int nlines, - int y, int x, size_t sz) + int y, int x, const void *data, size_t sz) { struct hexedit *buf; @@ -39,6 +39,10 @@ struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, int nlines, goto fail; } + if (data) { + memcpy(buf->data, data, sz); + } + buf->len = sz; buf->alloc_size = sz; buf->win = derwin(parent, nlines, LINE_WIDTH, y, x); diff --git a/source3/utils/regedit_hexedit.h b/source3/utils/regedit_hexedit.h index 1a2db912be..bca8324d8d 100644 --- a/source3/utils/regedit_hexedit.h +++ b/source3/utils/regedit_hexedit.h @@ -41,7 +41,7 @@ struct hexedit { }; struct hexedit *hexedit_new(TALLOC_CTX *ctx, WINDOW *parent, int nlines, - int y, int x, size_t sz); + int y, int x, const void *data, size_t sz); void hexedit_set_cursor(struct hexedit *buf); void hexedit_refresh(struct hexedit *buf); void hexedit_driver(struct hexedit *buf, int c); -- cgit