/* Creates a link and registers it in SD.
*/
SD_link_t __SD_link_create(void *surf_link, void *data) {
+
+ SD_link_t link;
+ const char *name;
+
SD_CHECK_INIT_DONE();
xbt_assert0(surf_link != NULL, "surf_link is NULL !");
- SD_link_t link = xbt_new0(s_SD_link_t, 1);
+ link = xbt_new(s_SD_link_t, 1);
link->surf_link = surf_link;
link->data = data; /* user data */
- const char *name = SD_link_get_name(link);
+ name = SD_link_get_name(link);
xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the link to the dictionary */
sd_global->link_count++;
* \see SD_link_get_number()
*/
const SD_link_t* SD_link_get_list(void) {
- SD_CHECK_INIT_DONE();
- xbt_assert0(SD_link_get_number() > 0, "There is no link!");
- SD_link_t *array = sd_global->link_list;
xbt_dict_cursor_t cursor;
char *key;
void *data;
int i;
+
+ SD_CHECK_INIT_DONE();
+ xbt_assert0(SD_link_get_number() > 0, "There is no link!");
- if (array == NULL) { /* this is the first time the function is called */
- array = xbt_new0(SD_link_t, sd_global->link_count);
+ if (sd_global->link_list == NULL) { /* this is the first time the function is called */
+ sd_global->link_list = xbt_new(SD_link_t, sd_global->link_count);
i = 0;
xbt_dict_foreach(sd_global->links, cursor, key, data) {
- array[i++] = (SD_link_t) data;
+ sd_global->link_list[i++] = (SD_link_t) data;
}
}
- return array;
+ return sd_global->link_list;
}
/**