Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adapts implementation to changes of header file

	- change of dict_free callback signature
	- position parameter is long now
adds callback calls for deletion of list/dict entries
  • Loading branch information...
commit 8bcecae2441cc12cfd39447959a1474be540b1b1 1 parent 9752ed3
Stefan authored
Showing with 15 additions and 15 deletions.
  1. +3 −5 drmaa2-dict.c
  2. +9 −9 drmaa2-list.c
  3. +3 −1 drmaa2.c
View
8 drmaa2-dict.c
@@ -26,11 +26,7 @@ drmaa2_error drmaa2_dict_free(drmaa2_dict d)
{
tmp = head;
head = head->next;
- if (d->free_entry != NULL)
- {
- d->free_entry((char *)tmp->key);
- d->free_entry((char *)tmp->value);
- }
+ if (d->free_entry != NULL) d->free_entry((char *)tmp->key, (char *)tmp->value);
free(tmp);
}
free(d);
@@ -95,6 +91,7 @@ drmaa2_error drmaa2_dict_del(drmaa2_dict d, const char * key)
{
d->head = current_item->next;
}
+ if (d->free_entry != NULL) d->free_entry((char *)current_item->key, (char *)current_item->value);
free(current_item);
return DRMAA2_SUCCESS;
}
@@ -123,6 +120,7 @@ drmaa2_error drmaa2_dict_set(drmaa2_dict d, const char * key, const char * val)
if (!strcmp(current_item->key, key))
{
// found -> replace
+ if (d->free_entry != NULL) d->free_entry(NULL, (char *)current_item->value);
current_item->value = val;
return DRMAA2_SUCCESS;
}
View
18 drmaa2-list.c
@@ -38,6 +38,7 @@ drmaa2_error drmaa2_list_free (drmaa2_list l)
{
tmp = head;
head = tmp->next;
+ if (l->free_entry != NULL) l->free_entry((void *)tmp->data);
free(tmp);
}
free(l);
@@ -45,12 +46,13 @@ drmaa2_error drmaa2_list_free (drmaa2_list l)
}
-const void *drmaa2_list_get (drmaa2_list l, int pos)
+const void *drmaa2_list_get (const drmaa2_list l, long pos)
{
if (pos < 0 || pos >= l->size)
return NULL;
+
drmaa2_list_item current_item = (drmaa2_list_item)l->head;
- int i;
+ long i;
for (i = 0; i < pos; i++)
current_item = current_item->next;
return current_item->data;
@@ -84,7 +86,7 @@ drmaa2_error drmaa2_list_add (drmaa2_list l, const void * value)
return DRMAA2_SUCCESS;
}
-drmaa2_error drmaa2_list_del (drmaa2_list l, int pos)
+drmaa2_error drmaa2_list_del (drmaa2_list l, long pos)
{
if (pos < 0 || pos >= l->size)
return DRMAA2_INVALID_ARGUMENT;
@@ -95,29 +97,27 @@ drmaa2_error drmaa2_list_del (drmaa2_list l, int pos)
drmaa2_list_item to_delete = current_item;
l->head = to_delete->next;
l->size--;
+ if (l->free_entry != NULL) l->free_entry((void *)to_delete->data);
free(to_delete);
return DRMAA2_SUCCESS;
}
- int i;
+ long i;
for (i = 0; i < pos-1; i++)
current_item = current_item->next;
//current_item points to the item before the one we want to remove
drmaa2_list_item to_delete = current_item->next;
current_item->next = to_delete->next;
l->size--;
- if (l->free_entry != NULL)
- {
- l->free_entry((void *)to_delete->data);
- }
+ if (l->free_entry != NULL) l->free_entry((void *)to_delete->data);
free(to_delete);
return DRMAA2_SUCCESS;
}
-int drmaa2_list_size (const drmaa2_list l)
+long drmaa2_list_size (const drmaa2_list l)
{
return l->size;
}
View
4 drmaa2.c
@@ -147,6 +147,7 @@ drmaa2_r drmaa2_rsession_request_reservation(const drmaa2_rsession rs, const drm
char *drmaa2_r_get_id(const drmaa2_r r)
{
+ //TODO return copy
return (char *)r->id;
}
@@ -206,7 +207,8 @@ drmaa2_j drmaa2_jsession_run_job(const drmaa2_jsession js, const drmaa2_jtemplat
char *drmaa2_j_get_id(const drmaa2_j j)
{
- return j->id;
+ //TODO: return copy
+ return (char *)j->id;
}
Please sign in to comment.
Something went wrong with that request. Please try again.