Code review comment for lp:~ken-vandine/gwibber/lp_959068

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Two test cases, the first one crashes the second one doesn't. Should validate the work around.

/*
 * build with:
 * valac --pkg gee-1.0 gee-test1.vala -o gee-test1
 */

static int main(string[] args)
{
  var map = new Gee.HashMap <string, string?> ();
  map["one"] = "one";
  map["two"] = "two";
  map["three"] = "three";
  map["four"] = "four";

  print ("map size is %d\n", map.size);

  foreach (var v in map.entries)
  {
    print ("Found %s\n", v.value);
    map.unset(v.key);
  }

  print ("map size is %d\n", map.size);

  return 0;
}
ken@trabajo:~/src/gwibber/lp_959068$ cat examples/gee-test2.vala
/*
 * build with:
 * valac --pkg gee-1.0 gee-test2.vala -o gee-test2
 */

static int main(string[] args)
{
  var map = new Gee.HashMap <string, string?> ();
  map["one"] = "one";
  map["two"] = "two";
  map["three"] = "three";
  map["four"] = "four";

  print ("map size is %d\n", map.size);

  var to_remove = new GLib.List <string> ();

  foreach (var v in map.entries)
  {
    print ("Found %s\n", v.value);
    to_remove.append (v.key);
  }
  foreach (var v in to_remove)
    map.unset(v);

  print ("map size is %d\n", map.size);

  return 0;
}

« Back to merge proposal