diff options
author | Matthew Garrett <mjg@redhat.com> | 2010-09-09 14:08:53 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2010-09-09 14:08:53 -0400 |
commit | 5d5396bc125f2a180ed773c8bc077a694a2df178 (patch) | |
tree | 85c06fa782fbab9dad3c748185ec7e4bda2391c5 | |
parent | 531592abd27942ad84c27d9911daeac0ffa9cf74 (diff) |
Add a destroy function
-rw-r--r-- | libbacklight.c | 13 | ||||
-rw-r--r-- | libbacklight.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libbacklight.c b/libbacklight.c index e2aaae0..c2cc900 100644 --- a/libbacklight.c +++ b/libbacklight.c @@ -105,6 +105,17 @@ out: return ret; } +void backlight_destroy(struct backlight *backlight) +{ + if (!backlight) + return; + + if (backlight->path) + free(backlight->path); + + free(backlight); +} + struct backlight *backlight_init(struct pci_device *dev, int card, int connector_type, int connector_type_id) { @@ -172,6 +183,8 @@ struct backlight *backlight_init(struct pci_device *dev, int card, if (ret < 0) goto out; + buffer[ret] = '\0'; + parent = basename(buffer); if (entry_type == BACKLIGHT_RAW) { diff --git a/libbacklight.h b/libbacklight.h index 20981bd..baf7e8a 100644 --- a/libbacklight.h +++ b/libbacklight.h @@ -13,6 +13,7 @@ struct backlight { enum backlight_type type; }; +void backlight_destroy(struct backlight *backlight); struct backlight *backlight_init(struct pci_device *dev, int card, int connector_type, int connector_type_id); long backlight_get_brightness(struct backlight *backlight); |