Re: a question about g_strconcat()
- From: Bernhard Schuster <schuster bernhard googlemail com>
- To: Cifer Lee <mantianyu gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: a question about g_strconcat()
- Date: Thu, 28 Feb 2013 12:27:14 +0001
I answered that some time ago:
http://stackoverflow.com/questions/11486704/c-sql-query-building-made-easy/11725655#11725655
On Thu, Feb 28, 2013 at 1:22 PM, Cifer Lee <mantianyu gmail com> wrote:
first, I will show some lines.
[code]
gchar *str_sample = g_strconcat("I have a", "dream that", NULL);
str_sample = g_strconcat(str_sample, " one day", NULL);
str_sample = g_strconcat(str_sample, " we can be friends.", NULL);
// do some work with str_sample
g_free(str_sample);
[/code]
if, for some reasons, I must call g_strconcat() three times, or in
concrete, I must follow some conditions to determine whether should I
concatenate each of the three phrases.... okay, actually, I am writing a
sql query phrase, like this:
if the parameter an_id is a empty string, then I will not append it to the
select phrase.
select * from a_table where 1=1 and `id`='an_id' and `name`='a_name'
actually, I have debug my program and find that each time the str_sample
variable has been assigned a different address. But I'm not sure the
internal mechanism of g_strconcat(), whether it apply for a totally new
space or a space that may overlap with the earlier applied space, if the
latter, then I can't free the earlier applied space, and I think it may
lead to memory leak.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]