summaryrefslogtreecommitdiff
path: root/libkms
diff options
context:
space:
mode:
Diffstat (limited to 'libkms')
-rw-r--r--libkms/api.c22
-rw-r--r--libkms/libkms.h4
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