+ rfx_free(map);
+}
+
+// ------------------------------- array_t --------------------------------------
+
+array_t* array_new() {
+ array_t*d = malloc(sizeof(array_t));
+ memset(d, 0, sizeof(array_t));
+ d->entry2pos = dict_new();
+ return d;
+}
+array_t* array_new2(type_t*type) {
+ array_t*d = malloc(sizeof(array_t));
+ memset(d, 0, sizeof(array_t));
+ d->entry2pos = dict_new2(type);
+ return d;
+}
+void*array_getkey(array_t*array, int nr) {
+ if(nr > array->num || nr<0) {
+ printf("error: reference to element %d in array[%d]\n", nr, array->num);
+ *(int*)0 = 0xdead;
+ return 0;
+ }
+ return array->d[nr].name;
+}
+void*array_getvalue(array_t*array, int nr) {
+ if(nr > array->num || nr<0) {
+ printf("error: reference to element %d in array[%d]\n", nr, array->num);
+ *(int*)0 = 0xdead;
+ return 0;
+ }
+ return array->d[nr].data;
+}
+int array_append(array_t*array, const void*name, void*data) {
+ while(array->size <= array->num) {
+ array->size += 64;
+ if(!array->d) {
+ array->d = malloc(sizeof(array_entry_t)*array->size);
+ } else {
+ array->d = realloc(array->d, sizeof(array_entry_t)*array->size);
+ }
+ }
+
+ dictentry_t*e = dict_put(array->entry2pos, name, (void*)(ptroff_t)(array->num+1));
+
+ if(name) {
+ array->d[array->num].name = e->key;
+ } else {
+ array->d[array->num].name = 0;
+ }
+ array->d[array->num].data = (void*)data;
+ return array->num++;
+}
+int array_find(array_t*array, const void*name)
+{
+ int pos = (int)(ptroff_t)dict_lookup(array->entry2pos, name);
+ return pos-1;
+}
+int array_find2(array_t*array, const void*name, void*data)
+{
+ dict_t*h= array->entry2pos;
+ dictentry_t*e = dict_get_slot(array->entry2pos, name);
+
+ while(e) {
+ int index = ((int)(ptroff_t)e->data) - 1;
+ if(h->key_type->equals(e->key, name) && array->d[index].data == data) {
+ return index;
+ }
+ e = e->next;
+ }
+ return -1;
+}
+int array_update(array_t*array, const void*name, void*data) {
+ int pos = array_find(array, name);
+ if(pos>=0) {
+ array->d[pos].data = data;
+ return pos;
+ }
+ return array_append(array, name, data);
+}
+int array_append_if_new(array_t*array, const void*name, void*data) {
+ int pos = array_find(array, name);
+ if(pos>=0)
+ return pos;
+ return array_append(array, name, data);
+}
+void array_free(array_t*array) {
+ dict_destroy(array->entry2pos);
+ if(array->d) {
+ free(array->d);array->d = 0;
+ }
+ free(array);