summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagappan <nagappan>2005-07-28 10:02:53 +0000
committernagappan <nagappan>2005-07-28 10:02:53 +0000
commit5b647ec498e5ce4bebdbaa3168cf45d16a947ccc (patch)
tree6247eefc96e41fc8eca693dc2b9c439be93d8348
parent821f151c07e13f146a1ea925c7d38853bbba524c (diff)
Converted all asprintf to g_strdup_printf mainly to work with solaris platform
-rw-r--r--appmap-gen.c22
-rw-r--r--parser.c14
2 files changed, 21 insertions, 15 deletions
diff --git a/appmap-gen.c b/appmap-gen.c
index 7b0b8be..d38c410 100644
--- a/appmap-gen.c
+++ b/appmap-gen.c
@@ -181,20 +181,21 @@ int check_duplicate_entries (char *gui_map_filename)
if (token)
{
entry = strdup (token);
- asprintf(&char_line,"%d",line_no);
- if(!g_hash_table_lookup_extended(appmap,entry,(gpointer) &orig_key,(gpointer) &value))
+ char_line = g_strdup_printf ("%d", line_no);
+ if (!g_hash_table_lookup_extended (appmap, entry,
+ (gpointer) &orig_key, (gpointer) &value))
{
- g_hash_table_insert (appmap, entry, char_line);
+ g_hash_table_insert (appmap, entry, char_line);
continue;
}
else
{
- printf("DUPLICATE : Line no:%s :%s",char_line,data);
+ g_print ("DUPLICATE : Line no:%s :%s", char_line, data);
continue;
- }
+ }
}
- }
- free(data);
+ }
+ g_free (data);
}
}
@@ -218,12 +219,13 @@ int main (int argc, char *argv[])
}
application_name = strdup (argv[1]);
- asprintf (&map_filename, "%s.map", argv[1]);
+ map_filename = g_strdup_printf ("%s.map", argv[1]);
init_error = SPI_init ();
if (init_error)
{
g_warning ("Error: SPI Init\n");
+ g_free (map_filename);
return init_error;
}
@@ -234,8 +236,8 @@ int main (int argc, char *argv[])
check_duplicate_entries (map_filename);
- free (application_name);
- free (map_filename);
+ g_free (application_name);
+ g_free (map_filename);
leaked = SPI_exit ();
diff --git a/parser.c b/parser.c
index 06f2381..1faeca1 100644
--- a/parser.c
+++ b/parser.c
@@ -1578,13 +1578,17 @@ FILE *open_appmap (char *app_name)
{
FILE *fp = NULL;
char *appmap_file = NULL;
- asprintf (&appmap_file, "%s.map", app_name);
+ appmap_file = g_strdup_printf ("%s.map", app_name);
fp = fopen (appmap_file, "w");
if (fp == NULL)
- return NULL;
+ {
+ g_free (appmap_file);
+ return NULL;
+ }
application_name = strdup (app_name);
free (app_name);
+ g_free (appmap_file);
return fp;
}
@@ -1608,7 +1612,7 @@ int close_appmap (FILE *fp)
int do_action (char *name, Accessible *object, int skip)
{
- int size = 0, status = 0;
+ int status = 0;
FILE *tempfp;
char *tmp = NULL;
char *data = NULL;
@@ -1619,7 +1623,7 @@ int do_action (char *name, Accessible *object, int skip)
extern char *application_name;
tmp = g_get_current_dir ();
- asprintf (&dir_name, "%s/tmpmapdir", tmp);
+ dir_name = g_strdup_printf ("%s/tmpmapdir", tmp);
free (tmp);
status = mkdir (dir_name, S_IRWXU | S_IRUSR | S_IXUSR | S_IROTH | S_IXOTH);
@@ -1639,7 +1643,7 @@ int do_action (char *name, Accessible *object, int skip)
data = tmp;
}
- size = asprintf (&file_name, "%s/%s.map", dir_name, data);
+ file_name = g_strdup_printf ("%s/%s.map", dir_name, data);
free (data);
free (dir_name);