diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2010-12-09 23:36:31 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-12 23:10:34 -0800 |
commit | c80650fddec8596ef7278e37aa12ce2076c54e93 (patch) | |
tree | 9a8ab01634defba15b0135ccce552e0c655da3e8 | |
parent | ac07da253415ccb8b6322feedf7969967357050e (diff) |
Convert ResConfig.c to use XtAsprintf() instead of XtMalloc + sprintf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/ResConfig.c | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/src/ResConfig.c b/src/ResConfig.c index 63afb18..68da536 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -174,18 +174,13 @@ _set_resource_values ( * create resource name string */ if (resource_name) { - temp = XtMalloc (sizeof(char) * - (2 + strlen(cur->core.name) - + strlen(resource_name))); - sprintf (temp, ".%s%s", cur->core.name, resource_name); + XtAsprintf (&temp, ".%s%s", cur->core.name, resource_name); XtFree (resource_name); } else if (!XtIsWidget (cur) || !cur->core.name) { cur = XtParent(cur); continue; } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen(cur->core.name))); - sprintf (temp, ".%s", cur->core.name); + XtAsprintf (&temp, ".%s", cur->core.name); } resource_name = temp; @@ -197,31 +192,19 @@ _set_resource_values ( (ApplicationShellWidget) (cur); if (resource_class) { - temp = XtMalloc (sizeof(char) * - (2 + strlen(top->application.class) - + strlen(resource_class))); - sprintf (temp, ".%s%s", + XtAsprintf (&temp, ".%s%s", top->application.class, resource_class); } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen(top->application.class))); - sprintf (temp, ".%s", + XtAsprintf (&temp, ".%s", top->application.class); } } else { if (resource_class) { - temp = XtMalloc (sizeof(char) * - (2 + strlen( - cur->core.widget_class->core_class.class_name) - + strlen(resource_class))); - sprintf (temp, ".%s%s", + XtAsprintf (&temp, ".%s%s", cur->core.widget_class->core_class.class_name, resource_class); } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen( - cur->core.widget_class->core_class.class_name))); - sprintf (temp, ".%s", + XtAsprintf (&temp, ".%s", cur->core.widget_class->core_class.class_name); } } @@ -235,9 +218,7 @@ _set_resource_values ( /* * add the resource name to the end of the resource name string */ - temp = XtMalloc (2 + strlen(resource_name) + - strlen(resources_return[res_index].resource_name)); - sprintf (temp, "%s.%s", resource_name, + XtAsprintf (&temp, "%s.%s", resource_name, resources_return[res_index].resource_name); if (resource_name != NULL) XtFree (resource_name); @@ -246,9 +227,7 @@ _set_resource_values ( /* * add the resource class to the end of the resource class string */ - temp = XtMalloc (2 + strlen(resource_class) + - strlen(resources_return[res_index].resource_class)); - sprintf (temp, "%s.%s", resource_class, + XtAsprintf (&temp, "%s.%s", resource_class, resources_return[res_index].resource_class); if (resource_class != NULL) XtFree (resource_class); @@ -757,8 +736,7 @@ _search_widget_tree ( */ } else { if (remainder[0] != '*' && remainder[0] != '.') { - copy = XtMalloc (strlen(remainder) + 2); - sprintf (copy, ".%s", remainder); + XtAsprintf (©, ".%s", remainder); XtFree (remainder); remainder = copy; } |