[pacman-dev] [PATCH] New alpm_list_join function

Dan McGee dpmcgee at gmail.com
Tue Nov 20 07:47:36 EST 2007


On Nov 20, 2007 2:10 AM, Nagy Gabor <ngaba at bibl.u-szeged.hu> wrote:
> Patch attached
> Bye

There isn't one comment in here, and that needs to change. Our list
tail pointer makes it a bit hard to tell what is going on without
comments, so can you please add one?

Something like (but don't copy this if its wrong!):

/* tmp is used to hold the original tail of first,
  and the tail pointer of the joined list will point
  to the tail of *second */

Wouldn't *last even be better than *tmp?

+alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second)
+{
+	alpm_list_t *tmp;
+	if (first == NULL) {
+		return second;
+	}
+	if (second == NULL) {
+		return first;
+	}
+	tmp = first->prev;
+	tmp->next = second;
+	first->prev = second->prev;
+	second->prev = tmp;
+
+	return(first);
+}




More information about the pacman-dev mailing list