struct mlistelem * mlist_replace(mlist_t list, void *data) { struct mlistelem *e; e = mlist_get(list,data); if (e == NULL) return NULL; memcpy(mlistelem_dataptr(e), data,list->data_size); return e; }
MList* mlist_insert(MList* list, void* data, int position) { MList *new_list; MList *tmp_list; if (position < 0) return mlist_append(list, data); else if (position == 0) return mlist_prepend(list, data); tmp_list = mlist_get(list, position); if (!tmp_list) return mlist_append (list, data); new_list = mlist_new(); new_list->data = data; new_list->prev = tmp_list->prev; tmp_list->prev->next = new_list; new_list->next = tmp_list; tmp_list->prev = new_list; return list; }