From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8cnD-0004I5-TA for qemu-devel@nongnu.org; Fri, 16 Mar 2012 15:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8cnB-0003hl-59 for qemu-devel@nongnu.org; Fri, 16 Mar 2012 15:26:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8cnA-0003gk-LM for qemu-devel@nongnu.org; Fri, 16 Mar 2012 15:26:24 -0400 From: Luiz Capitulino Date: Fri, 16 Mar 2012 16:26:19 -0300 Message-Id: <1331925981-19914-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1331925981-19914-1-git-send-email-lcapitulino@redhat.com> References: <1331925981-19914-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] Error: Introduce error_copy() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com Signed-off-by: Luiz Capitulino --- error.c | 13 +++++++++++++ error.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/error.c b/error.c index 990050f..d3455ab 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 6361f40..45ff6c1 100644 --- a/error.h +++ b/error.h @@ -35,6 +35,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. */ const char *error_get_pretty(Error *err); -- 1.7.9.2.384.g4a92a