4 * Copyright IBM, Corp. 2010
7 * Anthony Liguori <aliguori@us.ibm.com>
18 static void *mallocz(size_t size
)
29 Error
*error_new(const char *domain
,
38 e
= error_new_valist(domain
, code
, format
, ap
);
44 Error
*error_new_valist(const char *domain
,
51 e
= mallocz(sizeof(*e
));
52 e
->domain
= strdup(domain
);
55 if (vasprintf(&e
->message
, format
, ap
) == -1) {
62 Error
*error_new_literal(const char *domain
,
68 e
= mallocz(sizeof(*e
));
69 e
->domain
= strdup(domain
);
71 e
->message
= strdup(message
);
76 void error_set(Error
**errp
,
86 *errp
= error_new_valist(domain
, code
, format
, ap
);
91 bool error_is_set(Error
**errp
)
99 void error_propagate(Error
**errp
,
109 Error
*error_copy(const Error
*err
)
111 return error_new_literal(err
->domain
,
116 void error_free(Error
*e
)