--- clipboard.ccg.orig	2009-06-18 00:16:05.429600954 +0100
+++ clipboard.ccg	2009-06-18 00:16:59.237571924 +0100
@@ -329,8 +329,7 @@
 
 Glib::StringArrayHandle Clipboard::wait_for_targets() const
 {
-  std::list<Glib::ustring> listTargets;
-
+  char **array;
   //Get a newly-allocated array of atoms:
   GdkAtom* targets = 0;
   gint n_targets = 0;
@@ -338,20 +337,18 @@
   if(!test)
     n_targets = 0; //otherwise it will be -1.
 
+  if (n_targets == 0)
+    return Glib::StringArrayHandle (NULL, 0, Glib::OWNERSHIP_DEEP);
+
+  array = static_cast<char **>(g_malloc (n_targets * sizeof (char *)));
+
   //Add the targets to the C++ container:
   for(int i = 0; i < n_targets; i++)
   {
     //Convert the atom to a string:
-    gchar* const atom_name = gdk_atom_name(targets[i]);
-
-    Glib::ustring target;
-    if(atom_name)
-      target = Glib::ScopedPtr<char>(atom_name).get(); //This frees the gchar*.
-
-    listTargets.push_back(target);
+    array[i] = gdk_atom_name(targets[i]);
   }
-
-  return listTargets;
+  return Glib::StringArrayHandle (array, n_targets, Glib::OWNERSHIP_DEEP);
 }
 
 void Clipboard::set_can_store(const ArrayHandle_TargetEntry& targets)
