From ed5b60850f610acca9249bf1f15f9e5806bb739d Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 00:43:47 +0100 Subject: [PATCH 1/5] version bump --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e9f0375..fbce5f2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.68]) -AC_INIT([taskrambler], [0.1.5], [Georg Hopp ]) +AC_INIT([taskrambler], [0.1.6], [Georg Hopp ]) LT_INIT AM_INIT_AUTOMAKE #AM_INIT_AUTOMAKE([subdir-objects]) From 815f42e1749b2fabc13ab24c16f84122ced978b2 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 12:25:12 +0100 Subject: [PATCH 2/5] add facility to de/activate tree base memory optimizations --- configure.ac | 5 ++++- include/utils/memory.h | 3 --- src/Makefile.am | 7 ++++++- src/utils/memory.c | 31 +++++++++++++++++++++---------- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index fbce5f2..d1f0549 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_INIT([taskrambler], [0.1.6], [Georg Hopp ]) LT_INIT AM_INIT_AUTOMAKE #AM_INIT_AUTOMAKE([subdir-objects]) -AM_SILENT_RULES([yes]) +#AM_SILENT_RULES([yes]) AC_COPYRIGHT([Copyright © 2013 Georg Hopp]) AC_REVISION([$Revision: 0.02 $]) AC_CONFIG_SRCDIR([src/taskrambler.c]) @@ -19,6 +19,9 @@ AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) +m4_include([m4/memopt.m4]) +AC_MEM_OPT + PWD=$(/bin/pwd) AC_SUBST(PWD) diff --git a/include/utils/memory.h b/include/utils/memory.h index ed69685..e1a8fc9 100644 --- a/include/utils/memory.h +++ b/include/utils/memory.h @@ -25,7 +25,6 @@ #define CSTRA(val) val, sizeof(val)-1 //!< Const STRing Argument -#define FREE(val) (ffree((void**)&(val))) #define MEM_FREE(seg) (memFree((void **)&(seg))) #include @@ -36,8 +35,6 @@ void memFree(void **); size_t memGetSize(void *); void memCleanup(); -void ffree(void **); - #endif // __UTILS_MEMORY_H__ // vim: set ts=4 sw=4: diff --git a/src/Makefile.am b/src/Makefile.am index b0ee584..ffbd51f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,8 +32,13 @@ AM_CFLAGS = -Wall -I ../include/ bin_PROGRAMS = taskrambler + taskrambler_SOURCES = taskrambler.c $(IFACE) $(UTILS) -taskrambler_CFLAGS = $(CFLAGS) -Wall -DPWD=\"$(PWD)\" -I../include/ # $(COVERAGE_CFLAGS) +taskrambler_CFLAGS = $(CFLAGS) \ + -Wall \ + -DPWD=\"$(PWD)\" \ + $(MEM_OPT_FLAGS) \ + -I../include/ # $(COVERAGE_CFLAGS) taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap -lgdbm -luuid #taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS) diff --git a/src/utils/memory.c b/src/utils/memory.c index 1eeba16..870d374 100644 --- a/src/utils/memory.c +++ b/src/utils/memory.c @@ -782,6 +782,7 @@ memNewRef(void * mem) void * memMalloc(size_t size) { +#ifdef MEM_OPT struct memSegment * seg; //long psize = sysconf(_SC_PAGESIZE); long psize = 64; @@ -801,8 +802,10 @@ memMalloc(size_t size) seg = deleteElement(&segments, seg); } - return seg->ptr; +#else + return malloc(size); +#endif } /** @@ -816,17 +819,22 @@ memMalloc(size_t size) void * memCalloc(size_t nmemb, size_t size) { +#ifdef MEM_OPT size_t _size = nmemb * size; void * mem = memMalloc(_size); memset(mem, 0, _size); return mem; +#else + return calloc(nmemb, size); +#endif } void memFree(void ** mem) { +#ifdef MEM_OPT if (NULL != *mem) { struct memSegment * seg = (*mem - sizeof(struct memSegment)); @@ -838,11 +846,18 @@ memFree(void ** mem) *mem = NULL; } +#else + if (NULL != *mem) { + free(*mem); + *mem = NULL; + } +#endif } size_t memGetSize(void * mem) { +#ifdef MEM_OPT struct memSegment * segment; if (NULL == mem) { @@ -851,21 +866,17 @@ memGetSize(void * mem) segment = (struct memSegment *)(mem - sizeof(struct memSegment)); return segment->size; +#else + return 0; +#endif } void memCleanup() { +#ifdef MEM_OPT post(segments, segmentFree); +#endif } -void -ffree(void ** data) -{ - if (NULL != *data) { - free(*data); - *data = NULL; - } -} - // vim: set ts=4 sw=4: From 1897c819556cff1993a690e6d725df7e72c08fea Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 14:12:53 +0100 Subject: [PATCH 3/5] fix remove of user. As email is in that case a part of credential it must be set to NULL before delete. --- src/application/login.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/application/login.c b/src/application/login.c index 7b4a966..b661911 100644 --- a/src/application/login.c +++ b/src/application/login.c @@ -54,6 +54,7 @@ applicationLogin( // this is an ldap user that has not yet set // additional user informations. /* @TODO again...change the keys to id's */ + session->user->email = NULL; delete(session->user); session->user = new(User, CRED_PWD(credential).user, From 3455ad7522364990eb662789b0793ac2dc7e61ba Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 14:13:46 +0100 Subject: [PATCH 4/5] fix use of uninitialized value --- src/auth/storage/hash_pw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/storage/hash_pw.c b/src/auth/storage/hash_pw.c index 9614630..8fad687 100644 --- a/src/auth/storage/hash_pw.c +++ b/src/auth/storage/hash_pw.c @@ -78,7 +78,7 @@ hash_pw( unsigned char ** salt) { if (NULL == *salt) { - *salt = memMalloc(SALT_SIZE * sizeof(unsigned char)); + *salt = memCalloc(SALT_SIZE, sizeof(unsigned char)); if (0 > RAND_pseudo_bytes(*salt, SALT_SIZE)) { MEM_FREE(*salt); return FALSE; From d924a71f0d7b6f40165569bc815bcabd0de467ee Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 14:14:34 +0100 Subject: [PATCH 5/5] use silent build again --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d1f0549..542ce32 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_INIT([taskrambler], [0.1.6], [Georg Hopp ]) LT_INIT AM_INIT_AUTOMAKE #AM_INIT_AUTOMAKE([subdir-objects]) -#AM_SILENT_RULES([yes]) +AM_SILENT_RULES([yes]) AC_COPYRIGHT([Copyright © 2013 Georg Hopp]) AC_REVISION([$Revision: 0.02 $]) AC_CONFIG_SRCDIR([src/taskrambler.c])