Ticket #3555: 0003-button_get_text-shouldn-t-return-const.patch

File 0003-button_get_text-shouldn-t-return-const.patch, 1.3 KB (added by mooffie, 8 years ago)
  • lib/widget/button.c

    From 078f46752f2fed4df0f441ef41563144984b4c69 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Fri, 13 Nov 2015 16:11:29 +0200
    Subject: [PATCH] button_get_text() shouldn't return 'const'.
    
    As it's a newly allocated string which the caller needs to free.
    ---
     lib/widget/button.c | 2 +-
     lib/widget/button.h | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/lib/widget/button.c b/lib/widget/button.c
    index 055602e..cf7de6d 100644
    a b button_new (int y, int x, int action, button_flags_t flags, const char *text, bc 
    222222 
    223223/* --------------------------------------------------------------------------------------------- */ 
    224224 
    225 const char * 
     225char * 
    226226button_get_text (const WButton * b) 
    227227{ 
    228228    if (b->text.hotkey != NULL) 
  • lib/widget/button.h

    diff --git a/lib/widget/button.h b/lib/widget/button.h
    index f85be8b..278b2d3 100644
    a b typedef struct WButton 
    4646 
    4747WButton *button_new (int y, int x, int action, button_flags_t flags, const char *text, 
    4848                     bcback_fn callback); 
    49 const char *button_get_text (const WButton * b); 
     49char *button_get_text (const WButton * b); 
    5050void button_set_text (WButton * b, const char *text); 
    5151int button_get_len (const WButton * b); 
    5252