From: Luiz Capitulino Date: Mon, 5 Dec 2011 18:04:05 +0000 (-0200) Subject: Error: Introduce error_copy() X-Git-Tag: v1.1-rc0~223^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79020cfcbb78a85768174bb93ee3b7cfc6ffa353;p=thirdparty%2Fqemu.git Error: Introduce error_copy() Signed-off-by: Luiz Capitulino --- diff --git a/error.c b/error.c index 990050f792f..d3455ab9e6d 100644 --- a/error.c +++ b/error.c @@ -43,6 +43,19 @@ void error_set(Error **errp, const char *fmt, ...) *errp = err; } +Error *error_copy(const Error *err) +{ + Error *err_new; + + err_new = g_malloc0(sizeof(*err)); + err_new->msg = g_strdup(err->msg); + err_new->fmt = err->fmt; + err_new->obj = err->obj; + QINCREF(err_new->obj); + + return err_new; +} + bool error_is_set(Error **errp) { return (errp && *errp); diff --git a/error.h b/error.h index 6361f407fdd..45ff6c1ffe2 100644 --- a/error.h +++ b/error.h @@ -34,6 +34,11 @@ void error_set(Error **err, const char *fmt, ...) GCC_FMT_ATTR(2, 3); */ bool error_is_set(Error **err); +/** + * Returns an exact copy of the error passed as an argument. + */ +Error *error_copy(const Error *err); + /** * Get a human readable representation of an error object. */