src/plugin.c: Add assertions to detect if two linked lists are the same.
[collectd.git] / src / plugin.c
index 77041c9..2d431db 100644 (file)
@@ -923,7 +923,6 @@ static int plugin_notification_meta_add (notification_t *n,
 
   sstrncpy (meta->name, name, sizeof (meta->name));
   meta->type = type;
-  meta->next = NULL;
 
   switch (type)
   {
@@ -966,6 +965,7 @@ static int plugin_notification_meta_add (notification_t *n,
     }
   } /* switch (type) */
 
+  meta->next = NULL;
   tail = n->meta;
   while ((tail != NULL) && (tail->next != NULL))
     tail = tail->next;
@@ -1018,6 +1018,11 @@ int plugin_notification_meta_copy (notification_t *dst,
 {
   notification_meta_t *meta;
 
+  assert (dst != NULL);
+  assert (src != NULL);
+  assert (dst != src);
+  assert ((src->meta == NULL) || (src->meta != dst->meta));
+
   for (meta = src->meta; meta != NULL; meta = meta->next)
   {
     if (meta->type == NM_TYPE_STRING)