From 2ac6d4bf86f49293e4a5b8285baf085db794c8c3 Mon Sep 17 00:00:00 2001 From: domivogt Date: Sun, 22 Feb 2009 00:55:00 +0000 Subject: [PATCH] * Memory management fixes. --- ChangeLog | 18 +++++++++++++++--- fvwm/bindings.c | 2 -- libs/charmap.c | 24 +++++++++++++++--------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index cab9d6c9d..c15607cd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,18 @@ +2009-02-22 Dominik Vogt + + * fvwm/bindings.c (print_bindings): + slight cleanup + + * libs/charmap.c (charmap_table_to_string): + several memory menagement fixes. + 2009-02-22 Thomas Adam + * libs/charmap.c (charmap_table_to_string): - Reduce memory management on the stack, by making only those variables to - be accessed outside of the function charmap_table_to_string() allocated - on the heap instead. + Reduce memory management on the stack, by making only those variables + to be accessed outside of the function charmap_table_to_string() + allocated on the heap instead. + * fvwm/bindings.c (print_bindings): b->Action was previously checked whether it was NULL or not before printing its value to STDERR -- however, this caused a segfault when @@ -10,6 +20,7 @@ checking if it's NULL. This avoids segfaulting. 2009-02-05 Thomas Adam + * libs/charmap.c (charmap_table_to_string): * libs/charmap.h: Introduce charmap_to_string function which is used to build up a @@ -23,6 +34,7 @@ Add support for "binding" as an option to PrintInfo. 2009-02-19 Thomas Adam + * fvwm/placement.c (__pl_position_get_pos_simple): Force the window on-screen if using PositionPlacement UnderMouse. diff --git a/fvwm/bindings.c b/fvwm/bindings.c index 14c0aa313..4cf23a456 100644 --- a/fvwm/bindings.c +++ b/fvwm/bindings.c @@ -674,8 +674,6 @@ void print_bindings(void) switch (b->type) { case BIND_KEYPRESS: - fprintf(stderr, "\t%s", b->key_name); - break; case BIND_PKEYPRESS: fprintf(stderr, "\t%s", b->key_name); break; diff --git a/libs/charmap.c b/libs/charmap.c index 25a62b226..4df90e3e9 100644 --- a/libs/charmap.c +++ b/libs/charmap.c @@ -110,21 +110,27 @@ char *charmap_table_to_string(int mask, charmap_t *table) { char *allmods; int modmask; + char c[2]; + c[1] = 0; modmask = mask; - allmods = safecalloc(1, sizeof(charmap_t)); + allmods = safemalloc(sizeof(table->value) * 8 + 1); + *allmods = 0; for (; table->key !=0; table++) { - char c; - - strcpy(&c, (char *)&table->key); - c = toupper(c); - if (modmask & table->value) + c[0] = toupper(table->key); + if (mask == table->value) + { + /* exact match */ + strcpy(allmods, c); + break; + } + else if (modmask & table->value) { - modmask |= table->value; - strcat(allmods, &c); + /* incremental match */ + strcat(allmods, c); + modmask &= ~table->value; } - modmask &= ~table->value; } return allmods; -- 2.11.4.GIT