Re: [PATCH 5/5] clients: Use xstrdup instead of strdup

2014-05-09 Thread Kristian Høgsberg
On Wed, May 07, 2014 at 02:13:11AM +, Bryce W. Harrington wrote:
 
 Signed-off-by: Bryce Harrington b.harring...@samsung.com
 ---
  clients/editor.c   |   12 ++--
  clients/image.c|4 ++--
  clients/keyboard.c |   12 ++--
  clients/terminal.c |2 +-
  4 files changed, 15 insertions(+), 15 deletions(-)
 

This one looks good, but doesn't apply without the rest of the series.

Kristian

 diff --git a/clients/editor.c b/clients/editor.c
 index bda3e91..ece8b1d 100644
 --- a/clients/editor.c
 +++ b/clients/editor.c
 @@ -258,7 +258,7 @@ text_input_preedit_string(void *data,
   }
  
   text_entry_set_preedit(entry, text, entry-preedit_info.cursor);
 - entry-preedit.commit = strdup(commit);
 + entry-preedit.commit = xstrdup(commit);
   entry-preedit.attr_list = 
 pango_attr_list_ref(entry-preedit_info.attr_list);
  
   clear_pending_preedit(entry);
 @@ -562,7 +562,7 @@ text_entry_create(struct editor *editor, const char *text)
   entry = xzalloc(sizeof *entry);
   entry-widget = widget_add_widget(editor-widget, entry);
   entry-window = editor-window;
 - entry-text = strdup(text);
 + entry-text = xstrdup(text);
   entry-active = 0;
   entry-cursor = strlen(text);
   entry-anchor = entry-cursor;
 @@ -686,7 +686,7 @@ text_entry_update_layout(struct text_entry *entry)
   strcpy(text + entry-cursor + strlen(entry-preedit.text),
  entry-text + entry-cursor);
   } else {
 - text = strdup(entry-text);
 + text = xstrdup(entry-text);
   }
  
   if (entry-cursor != entry-anchor) {
 @@ -809,7 +809,7 @@ text_entry_commit_and_reset(struct text_entry *entry)
   char *commit = NULL;
  
   if (entry-preedit.commit)
 - commit = strdup(entry-preedit.commit);
 + commit = xstrdup(entry-preedit.commit);
  
   text_entry_reset_preedit(entry);
   if (commit) {
 @@ -832,7 +832,7 @@ text_entry_set_preedit(struct text_entry *entry,
   if (!preedit_text)
   return;
  
 - entry-preedit.text = strdup(preedit_text);
 + entry-preedit.text = xstrdup(preedit_text);
   entry-preedit.cursor = preedit_cursor;
  
   text_entry_update_layout(entry);
 @@ -1345,7 +1345,7 @@ main(int argc, char *argv[])
   editor.entry = text_entry_create(editor, Entry);
   editor.entry-click_to_show = click_to_show;
   if (preferred_language)
 - editor.entry-preferred_language = strdup(preferred_language);
 + editor.entry-preferred_language = xstrdup(preferred_language);
   editor.editor = text_entry_create(editor, Numeric);
   editor.editor-content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER;
   editor.editor-click_to_show = click_to_show;
 diff --git a/clients/image.c b/clients/image.c
 index cba68c5..b4a7bb8 100644
 --- a/clients/image.c
 +++ b/clients/image.c
 @@ -362,12 +362,12 @@ image_create(struct display *display, const char 
 *filename,
  
   image = xzalloc(sizeof *image);
  
 - copy = strdup(filename);
 + copy = xstrdup(filename);
   b = basename(copy);
   snprintf(title, sizeof title, Wayland Image - %s, b);
   free(copy);
  
 - image-filename = strdup(filename);
 + image-filename = xstrdup(filename);
   image-image = load_cairo_surface(filename);
  
   if (!image-image) {
 diff --git a/clients/keyboard.c b/clients/keyboard.c
 index cd1ad58..6b1e7a0 100644
 --- a/clients/keyboard.c
 +++ b/clients/keyboard.c
 @@ -440,12 +440,12 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
 *keyboard)
   keyboard-surrounding_text = surrounding_text;
   keyboard-surrounding_cursor += 
 strlen(keyboard-preedit_string);
   } else {
 - keyboard-surrounding_text = strdup(keyboard-preedit_string);
 + keyboard-surrounding_text = xstrdup(keyboard-preedit_string);
   keyboard-surrounding_cursor = strlen(keyboard-preedit_string);
   }
  
   free(keyboard-preedit_string);
 - keyboard-preedit_string = strdup();
 + keyboard-preedit_string = xstrdup();
  }
  
  static void
 @@ -757,7 +757,7 @@ handle_surrounding_text(void *data,
   struct virtual_keyboard *keyboard = data;
  
   free(keyboard-surrounding_text);
 - keyboard-surrounding_text = strdup(text);
 + keyboard-surrounding_text = xstrdup(text);
  
   keyboard-surrounding_cursor = cursor;
  }
 @@ -772,7 +772,7 @@ handle_reset(void *data,
  
   if (strlen(keyboard-preedit_string)) {
   free(keyboard-preedit_string);
 - keyboard-preedit_string = strdup();
 + keyboard-preedit_string = xstrdup();
   }
  }
  
 @@ -840,7 +840,7 @@ handle_preferred_language(void *data,
   keyboard-preferred_language = NULL;
  
   if (language)
 - keyboard-preferred_language = strdup(language);
 + keyboard-preferred_language = xstrdup(language);
  }
  
  

[PATCH 5/5] clients: Use xstrdup instead of strdup

2014-05-06 Thread Bryce W. Harrington

Signed-off-by: Bryce Harrington b.harring...@samsung.com
---
 clients/editor.c   |   12 ++--
 clients/image.c|4 ++--
 clients/keyboard.c |   12 ++--
 clients/terminal.c |2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index bda3e91..ece8b1d 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -258,7 +258,7 @@ text_input_preedit_string(void *data,
}
 
text_entry_set_preedit(entry, text, entry-preedit_info.cursor);
-   entry-preedit.commit = strdup(commit);
+   entry-preedit.commit = xstrdup(commit);
entry-preedit.attr_list = 
pango_attr_list_ref(entry-preedit_info.attr_list);
 
clear_pending_preedit(entry);
@@ -562,7 +562,7 @@ text_entry_create(struct editor *editor, const char *text)
entry = xzalloc(sizeof *entry);
entry-widget = widget_add_widget(editor-widget, entry);
entry-window = editor-window;
-   entry-text = strdup(text);
+   entry-text = xstrdup(text);
entry-active = 0;
entry-cursor = strlen(text);
entry-anchor = entry-cursor;
@@ -686,7 +686,7 @@ text_entry_update_layout(struct text_entry *entry)
strcpy(text + entry-cursor + strlen(entry-preedit.text),
   entry-text + entry-cursor);
} else {
-   text = strdup(entry-text);
+   text = xstrdup(entry-text);
}
 
if (entry-cursor != entry-anchor) {
@@ -809,7 +809,7 @@ text_entry_commit_and_reset(struct text_entry *entry)
char *commit = NULL;
 
if (entry-preedit.commit)
-   commit = strdup(entry-preedit.commit);
+   commit = xstrdup(entry-preedit.commit);
 
text_entry_reset_preedit(entry);
if (commit) {
@@ -832,7 +832,7 @@ text_entry_set_preedit(struct text_entry *entry,
if (!preedit_text)
return;
 
-   entry-preedit.text = strdup(preedit_text);
+   entry-preedit.text = xstrdup(preedit_text);
entry-preedit.cursor = preedit_cursor;
 
text_entry_update_layout(entry);
@@ -1345,7 +1345,7 @@ main(int argc, char *argv[])
editor.entry = text_entry_create(editor, Entry);
editor.entry-click_to_show = click_to_show;
if (preferred_language)
-   editor.entry-preferred_language = strdup(preferred_language);
+   editor.entry-preferred_language = xstrdup(preferred_language);
editor.editor = text_entry_create(editor, Numeric);
editor.editor-content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER;
editor.editor-click_to_show = click_to_show;
diff --git a/clients/image.c b/clients/image.c
index cba68c5..b4a7bb8 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -362,12 +362,12 @@ image_create(struct display *display, const char 
*filename,
 
image = xzalloc(sizeof *image);
 
-   copy = strdup(filename);
+   copy = xstrdup(filename);
b = basename(copy);
snprintf(title, sizeof title, Wayland Image - %s, b);
free(copy);
 
-   image-filename = strdup(filename);
+   image-filename = xstrdup(filename);
image-image = load_cairo_surface(filename);
 
if (!image-image) {
diff --git a/clients/keyboard.c b/clients/keyboard.c
index cd1ad58..6b1e7a0 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -440,12 +440,12 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
*keyboard)
keyboard-surrounding_text = surrounding_text;
keyboard-surrounding_cursor += 
strlen(keyboard-preedit_string);
} else {
-   keyboard-surrounding_text = strdup(keyboard-preedit_string);
+   keyboard-surrounding_text = xstrdup(keyboard-preedit_string);
keyboard-surrounding_cursor = strlen(keyboard-preedit_string);
}
 
free(keyboard-preedit_string);
-   keyboard-preedit_string = strdup();
+   keyboard-preedit_string = xstrdup();
 }
 
 static void
@@ -757,7 +757,7 @@ handle_surrounding_text(void *data,
struct virtual_keyboard *keyboard = data;
 
free(keyboard-surrounding_text);
-   keyboard-surrounding_text = strdup(text);
+   keyboard-surrounding_text = xstrdup(text);
 
keyboard-surrounding_cursor = cursor;
 }
@@ -772,7 +772,7 @@ handle_reset(void *data,
 
if (strlen(keyboard-preedit_string)) {
free(keyboard-preedit_string);
-   keyboard-preedit_string = strdup();
+   keyboard-preedit_string = xstrdup();
}
 }
 
@@ -840,7 +840,7 @@ handle_preferred_language(void *data,
keyboard-preferred_language = NULL;
 
if (language)
-   keyboard-preferred_language = strdup(language);
+   keyboard-preferred_language = xstrdup(language);
 }
 
 static const struct wl_input_method_context_listener 
input_method_context_listener = {
@@ -869,7 +869,7 @@ input_method_activate(void *data,