diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2009-12-04 16:06:42 +0100 |
---|---|---|
committer | Jakob Bornecrantz <jakob@vmware.com> | 2009-12-04 16:11:56 +0100 |
commit | 201f5795a26ae7b5580a35b24f4e89e5cd3455b1 (patch) | |
tree | a4c8f225beaa20e94a9f7116977ed924017fecb1 | |
parent | 8c0571a73399c372644c8d92a136a474f3e05d48 (diff) |
libkms: Change destroy api a bit
-rw-r--r-- | libkms/api.c | 22 | ||||
-rw-r--r-- | libkms/libkms.h | 4 |
2 files changed, 20 insertions, 6 deletions
diff --git a/libkms/api.c b/libkms/api.c index f15ee70b..6f899c41 100644 --- a/libkms/api.c +++ b/libkms/api.c @@ -54,9 +54,13 @@ int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out) return kms->get_prop(kms, key, out); } -int kms_destroy(struct kms_driver *kms) +int kms_destroy(struct kms_driver **kms) { - free(kms); + if (!(*kms)) + return 0; + + free(*kms); + *kms = NULL; return 0; } @@ -118,7 +122,17 @@ int kms_bo_unmap(struct kms_bo *bo) return bo->kms->bo_unmap(bo); } -int kms_bo_destroy(struct kms_bo *bo) +int kms_bo_destroy(struct kms_bo **bo) { - return bo->kms->bo_destroy(bo); + int ret; + + if (!(*bo)) + return 0; + + ret = (*bo)->kms->bo_destroy(*bo); + if (ret) + return ret; + + *bo = NULL; + return 0; } diff --git a/libkms/libkms.h b/libkms/libkms.h index 9cc8ae21..eb2ed893 100644 --- a/libkms/libkms.h +++ b/libkms/libkms.h @@ -58,12 +58,12 @@ enum kms_bo_type int kms_create(int fd, struct kms_driver **out); int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out); -int kms_destroy(struct kms_driver *kms); +int kms_destroy(struct kms_driver **kms); int kms_bo_create(struct kms_driver *kms, const unsigned *attr, struct kms_bo **out); int kms_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out); int kms_bo_map(struct kms_bo *bo, void **out); int kms_bo_unmap(struct kms_bo *bo); -int kms_bo_destroy(struct kms_bo *bo); +int kms_bo_destroy(struct kms_bo **bo); #endif |