From 5d5396bc125f2a180ed773c8bc077a694a2df178 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 9 Sep 2010 14:08:53 -0400 Subject: Add a destroy function --- libbacklight.c | 13 +++++++++++++ libbacklight.h | 1 + 2 files changed, 14 insertions(+) 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); -- cgit v1.2.3