From 9ef4282e9e32e857f4d0cac9df6d58f2cba159f4 Mon Sep 17 00:00:00 2001 From: reinelt Date: Wed, 3 Mar 2004 03:47:04 +0000 Subject: [lcd4linux @ 2004-03-03 03:47:04 by reinelt] big patch from Martin Hejl: - use qprintf() where appropriate - save CPU cycles on gettimeofday() - add quit() functions to free allocated memory - fixed lots of memory leaks git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@384 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- pid.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'pid.c') diff --git a/pid.c b/pid.c index bdf7737..743470a 100644 --- a/pid.c +++ b/pid.c @@ -1,4 +1,4 @@ -/* $Id: pid.c,v 1.3 2004/01/29 04:40:02 reinelt Exp $ +/* $Id: pid.c,v 1.4 2004/03/03 03:47:04 reinelt Exp $ * * PID file handling * @@ -22,6 +22,13 @@ * * * $Log: pid.c,v $ + * Revision 1.4 2004/03/03 03:47:04 reinelt + * big patch from Martin Hejl: + * - use qprintf() where appropriate + * - save CPU cycles on gettimeofday() + * - add quit() functions to free allocated memory + * - fixed lots of memory leaks + * * Revision 1.3 2004/01/29 04:40:02 reinelt * every .c file includes "config.h" now * @@ -62,7 +69,7 @@ #include "debug.h" #include "pid.h" - +#include "qprintf.h" int pid_init (const char *pidfile) { @@ -70,7 +77,7 @@ int pid_init (const char *pidfile) char buffer[16]; int fd, len, pid; - snprintf(tmpfile, sizeof(tmpfile), "%s.%s", pidfile, "XXXXXX"); + qprintf(tmpfile, sizeof(tmpfile), "%s.%s", pidfile, "XXXXXX"); if ((fd=mkstemp(tmpfile))==-1) { error ("mkstemp(%s) failed: %s", tmpfile, strerror(errno)); @@ -84,7 +91,7 @@ int pid_init (const char *pidfile) return -1; } - snprintf (buffer, sizeof(buffer), "%d\n", (int)getpid()); + qprintf(buffer, sizeof(buffer), "%d\n", (int)getpid()); if (write(fd, buffer, strlen(buffer))!=strlen(buffer)) { error ("write(%s) failed: %s", tmpfile, strerror(errno)); close(fd); -- cgit v1.2.3