提交 fa7f51b8 编写于 作者: J John Levon

introduce virSaveLastError(), virFreeError()

上级 1290b28f
Mon Feb 9 14:07:51 GMT 2009 John Levon <john.levon@sun.com>
* include/libvirt/virterror.h:
* src/libvirt_public.syms:
* src/virterror.c: introduce virSaveLastError(), virFreeError()
Mon Feb 9 10:21:33 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* src/virsh.c: Limit readonly history to 500 to avoid unbounded
......
......@@ -172,8 +172,10 @@ typedef void (*virErrorFunc) (void *userData, virErrorPtr error);
*/
virErrorPtr virGetLastError (void);
virErrorPtr virSaveLastError (void);
void virResetLastError (void);
void virResetError (virErrorPtr err);
void virFreeError (virErrorPtr err);
virErrorPtr virConnGetLastError (virConnectPtr conn);
void virConnResetLastError (virConnectPtr conn);
......
......@@ -247,4 +247,10 @@ LIBVIRT_0.6.0 {
} LIBVIRT_0.5.0;
LIBVIRT_0.6.1 {
global:
virFreeError;
virSaveLastError;
} LIBVIRT_0.6.0;
# .... define new API here using predicted next version number ....
......@@ -285,6 +285,27 @@ virCopyLastError(virErrorPtr to)
return to->code;
}
/**
* virSaveLastError:
*
* Save the last error into a new error object.
*
* Returns a pointer to the copied error or NULL if allocation failed.
* It is the caller's responsibility to free the error with
* virFreeError().
*/
virErrorPtr
virSaveLastError(void)
{
virErrorPtr to;
if (VIR_ALLOC(to) < 0)
return NULL;
virCopyLastError(to);
return to;
}
/**
* virResetError:
* @err: pointer to the virError to clean up
......@@ -303,6 +324,18 @@ virResetError(virErrorPtr err)
memset(err, 0, sizeof(virError));
}
/**
* virFreeError:
* @err: error to free
*
* Resets and frees the given error.
*/
void
virFreeError(virErrorPtr err)
{
virResetError(err);
VIR_FREE(err);
}
/**
* virResetLastError:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册