Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2264:44bb9a033407
Revert patch c1eb68306520
c1eb68306520 frees colors that could still be used for other nicknames.
Thanks to franky for the hint.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 30 Apr 2016 11:23:37 +0200 |
parents | 387cea2a1a81 |
children | f5402d705f67 |
comparison
equal
deleted
inserted
replaced
2263:223827268b2b | 2264:44bb9a033407 |
---|---|
202 | 202 |
203 GSList* spell_checkers = NULL; | 203 GSList* spell_checkers = NULL; |
204 #endif | 204 #endif |
205 | 205 |
206 typedef struct { | 206 typedef struct { |
207 int color_pair; | 207 int color_pair; |
208 int color_attrib; | 208 int color_attrib; |
209 } ccolor; | 209 } ccolor; |
210 | 210 |
211 typedef struct { | 211 typedef struct { |
212 char *status, *wildcard; | 212 char *status, *wildcard; |
213 ccolor *color; | 213 ccolor *color; |
348 scr_LogPrint(LPRINT_NORMAL, "No such color name"); | 348 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
349 g_free(snick); | 349 g_free(snick); |
350 g_free(mnick); | 350 g_free(mnick); |
351 } else { | 351 } else { |
352 nickcolor *nc = g_new(nickcolor, 1); | 352 nickcolor *nc = g_new(nickcolor, 1); |
353 nickcolor *oc; | |
354 ensure_string_htable(&nickcolors, NULL); | 353 ensure_string_htable(&nickcolors, NULL); |
355 nc->manual = TRUE; | 354 nc->manual = TRUE; |
356 nc->color = cl; | 355 nc->color = cl; |
357 // Free the struct, if any there already | 356 // Free the struct, if any there already |
358 if ((oc = g_hash_table_lookup(nickcolors, mnick))) { | 357 g_free(g_hash_table_lookup(nickcolors, mnick)); |
359 g_free(oc -> color); | |
360 g_free(oc); | |
361 } | |
362 // Save the new ones | 358 // Save the new ones |
363 g_hash_table_replace(nickcolors, mnick, nc); | 359 g_hash_table_replace(nickcolors, mnick, nc); |
364 g_hash_table_replace(nickcolors, snick, nc); | 360 g_hash_table_replace(nickcolors, snick, nc); |
365 need_update = TRUE; | 361 need_update = TRUE; |
366 } | 362 } |
424 scr_LogPrint(LPRINT_NORMAL, "No such color name"); | 420 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
425 return FALSE; | 421 return FALSE; |
426 } | 422 } |
427 if (found) { | 423 if (found) { |
428 rostercolor *rc = found->data; | 424 rostercolor *rc = found->data; |
429 g_free(rc->color); | 425 g_free(rc->color); |
430 rc->color = cl; | 426 rc->color = cl; |
431 } else { | 427 } else { |
432 rostercolor *rc = g_new(rostercolor, 1); | 428 rostercolor *rc = g_new(rostercolor, 1); |
433 rc->status = g_strdup(status); | 429 rc->status = g_strdup(status); |
434 rc->wildcard = g_strdup(wildcard); | 430 rc->wildcard = g_strdup(wildcard); |
581 } | 577 } |
582 g_free(ncolor_start); | 578 g_free(ncolor_start); |
583 } | 579 } |
584 if (!nickcols) { // Fallback to have something | 580 if (!nickcols) { // Fallback to have something |
585 nickcolcount = 1; | 581 nickcolcount = 1; |
586 nickcols = g_new(ccolor*, 1); | 582 nickcols = g_new(ccolor*, 1); |
587 *nickcols = g_new(ccolor, 1); | 583 *nickcols = g_new(ccolor, 1); |
588 (*nickcols)->color_pair = COLOR_GENERAL; | 584 (*nickcols)->color_pair = COLOR_GENERAL; |
589 (*nickcols)->color_attrib = A_NORMAL; | 585 (*nickcols)->color_attrib = A_NORMAL; |
590 } | 586 } |
591 } | 587 } |
592 | 588 |