summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-10-02 19:49:47 +0200
committerportix <none@none>2012-10-02 19:49:47 +0200
commit0ef10deba55e01d553b887c3017cf63fcbe16565 (patch)
tree5ed433ee0b5a21afa0de30c30a023b3ad45d8168 /src
parent430499af09b0ba3c44ef87c83b67a834b24ac40c (diff)
downloaddwb-0ef10deba55e01d553b887c3017cf63fcbe16565.zip
Create js-quark before creating any objects; don't allocation position string in dwb_update_status_text
Diffstat (limited to 'src')
-rw-r--r--src/dwb.c15
-rw-r--r--src/scripts.c4
2 files changed, 11 insertions, 8 deletions
diff --git a/src/dwb.c b/src/dwb.c
index 20831250..663206d7 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -613,13 +613,16 @@ dwb_update_status_text(GList *gl, GtkAdjustment *a) {
double lower = gtk_adjustment_get_lower(a);
double upper = gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a) + lower;
double value = gtk_adjustment_get_value(a);
- char *position =
- upper == lower ? g_strdup("[all]") :
- value == lower ? g_strdup("[top]") :
- value == upper ? g_strdup("[bot]") :
- g_strdup_printf("[%02d%%]", (int)(value * 100/upper + 0.5));
+ char position[7];
+ if (upper == lower)
+ strcpy(position, "[all]");
+ else if (value == lower)
+ strcpy(position, "[top]");
+ else if (value == upper)
+ strcpy(position, "[bot]");
+ else
+ snprintf(position, sizeof(position), "[%02d%%]", (int)(value * 100/upper + 0.5));
g_string_append(string, position);
- g_free(position);
}
if (v->status->scripts & SCRIPTS_BLOCKED) {
const char *format = v->status->scripts & SCRIPTS_ALLOWED_TEMPORARY
diff --git a/src/scripts.c b/src/scripts.c
index 1d8c6f6f..dbe8751a 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -1721,6 +1721,8 @@ get_property(JSContextRef ctx, JSObjectRef jsobj, JSStringRef js_name, JSValueRe
/* create_global_object {{{*/
static void
create_global_object() {
+ ref_quark = g_quark_from_static_string("dwb_js_ref");
+
JSStaticFunction global_functions[] = {
{ "execute", global_execute, kJSDefaultAttributes },
{ "exit", global_exit, kJSDefaultAttributes },
@@ -1973,8 +1975,6 @@ scripts_init(gboolean force) {
}
dwb.state.script_completion = NULL;
- ref_quark = g_quark_from_static_string("dwb_js_ref");
-
char *dir = util_get_data_dir(LIBJS_DIR);
if (dir != NULL) {
GString *content = g_string_new(NULL);