From 314a4b9ec91ddf87c56c875eeb54421e74d1fdba Mon Sep 17 00:00:00 2001 From: Marcos Medeiros Date: Wed, 28 Dec 2016 17:09:23 -0200 Subject: [PATCH 1/2] Add lcdFree --- devLib/lcd.c | 15 +++++++++++++++ devLib/lcd.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/devLib/lcd.c b/devLib/lcd.c index 6c0e474..512f049 100644 --- a/devLib/lcd.c +++ b/devLib/lcd.c @@ -493,3 +493,18 @@ int lcdInit (const int rows, const int cols, const int bits, return lcdFd ; } + + +/* + * lcdFree: + * Free a LCD handle. + ********************************************************************************* + */ + +void lcdFree (const int fd) +{ + if ((fd >= 0) && (fd < MAX_LCDS)) + { + lcds[fd] = NULL; + } +} \ No newline at end of file diff --git a/devLib/lcd.h b/devLib/lcd.h index 0a0e598..f478d37 100644 --- a/devLib/lcd.h +++ b/devLib/lcd.h @@ -47,6 +47,8 @@ extern int lcdInit (const int rows, const int cols, const int bits, const int d0, const int d1, const int d2, const int d3, const int d4, const int d5, const int d6, const int d7) ; +extern void lcdFree (const int fd); + #ifdef __cplusplus } #endif From 7adbd1939f9ff3e8841e0a447b6bbcfab45e419f Mon Sep 17 00:00:00 2001 From: Marcos Medeiros Date: Wed, 28 Dec 2016 18:11:16 -0200 Subject: [PATCH 2/2] Update lcd.c Free LCD handle slot. --- devLib/lcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devLib/lcd.c b/devLib/lcd.c index 512f049..24910a9 100644 --- a/devLib/lcd.c +++ b/devLib/lcd.c @@ -505,6 +505,7 @@ void lcdFree (const int fd) { if ((fd >= 0) && (fd < MAX_LCDS)) { + free(lcds[fd]); lcds[fd] = NULL; } -} \ No newline at end of file +}