Explorar o código

qdevice: Free memory used by log

Signed-off-by: Jan Friesse <jfriesse@redhat.com>

(cherry picked from corosync-qdevice project commit
 d9f47ac6f2b32f648e6c5db7f6908a1b953b04a9)
Jan Friesse %!s(int64=6) %!d(string=hai) anos
pai
achega
5e6174eed0
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      qdevices/log.c

+ 8 - 1
qdevices/log.c

@@ -32,6 +32,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdlib.h>
 #include <syslog.h>
 #include <stdio.h>
 #include <string.h>
@@ -70,6 +71,7 @@ int
 log_init(const char *ident, int target, int syslog_facility)
 {
 
+	free(log_config_ident);
 	log_config_ident = strdup(ident);
 
 	if (log_config_ident == NULL) {
@@ -149,6 +151,9 @@ log_close(void)
 	if (log_config_target & LOG_TARGET_SYSLOG) {
 		closelog();
 	}
+
+	free(log_config_ident);
+	log_config_ident = NULL;
 }
 
 void
@@ -169,7 +174,9 @@ void
 log_set_target(int target, int syslog_facility)
 {
 
-	log_close();
+	if (log_config_target & LOG_TARGET_SYSLOG) {
+		closelog();
+	}
 
 	log_config_target = target;
 	log_config_syslog_facility = syslog_facility;