~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/common/utility.c

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-07-12 09:36:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110712093646-yp9dbxan44dmw15h
Tags: 0.9-1
* New upstream release.
* Remove all patches now upstream; only patch for
  -Wno-error=unused-but-set-variable remains.
* Bump Standards-Version to 3.9.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    nstring = g_strdup(string); // otherwise it's a hell to decide whether to free this string later.
66
66
  return nstring;
67
67
}
 
68
 
 
69
gchar* dt_util_glist_to_str(const gchar* separator, GList * items, const unsigned int count)
 
70
{
 
71
  if(count == 0)
 
72
    return NULL;
 
73
 
 
74
  gchar *result = NULL;
 
75
 
 
76
  // add the entries to an char* array
 
77
  items = g_list_first(items);
 
78
  gchar** strings = g_malloc(sizeof(gchar*) * (count+1));
 
79
  if(items != NULL)
 
80
  {
 
81
    int i = 0;
 
82
    do
 
83
    {
 
84
      strings[i++] = items->data;
 
85
    }
 
86
    while((items=g_list_next(items)) != NULL);
 
87
    strings[i] = NULL;
 
88
  }
 
89
 
 
90
  // join them into a single string
 
91
  result = g_strjoinv(separator, strings);
 
92
 
 
93
  // free the GList and the array
 
94
  items = g_list_first(items);
 
95
  if(items != NULL)
 
96
  {
 
97
    do
 
98
    {
 
99
      g_free(items->data);
 
100
    }
 
101
    while((items=g_list_next(items)) != NULL);
 
102
  }
 
103
  g_list_free(items);
 
104
  if(strings != NULL)
 
105
    g_free(strings);
 
106
 
 
107
  return result;
 
108
}
 
109
 
 
110
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;