summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 71a0543)
raw | patch | inline | side by side (parent: 71a0543)
author | Florian Forster <octo@collectd.org> | |
Wed, 23 Nov 2011 13:28:01 +0000 (14:28 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 21 Jan 2012 10:20:20 +0000 (11:20 +0100) |
Change-Id: I8449e27c908cbe75ea4ea3b8dd4df556f9aec9e7
src/meta_data.c | patch | blob | history | |
src/meta_data.h | patch | blob | history |
diff --git a/src/meta_data.c b/src/meta_data.c
index aff3f8e589248b29f836566fd56314cc91b7b148..b502b377295141a8a095ba248d7e6de0ab285072 100644 (file)
--- a/src/meta_data.c
+++ b/src/meta_data.c
/**
* collectd - src/meta_data.c
- * Copyright (C) 2008,2009 Florian octo Forster
+ * Copyright (C) 2008-2011 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return (e);
} /* }}} meta_entry_t *md_entry_alloc */
+static meta_entry_t *md_entry_clone (const meta_entry_t *orig) /* {{{ */
+{
+ meta_entry_t *copy;
+
+ if (orig == NULL)
+ return (NULL);
+
+ copy = md_entry_alloc (orig->key);
+ copy->type = orig->type;
+ if (copy->type == MD_TYPE_STRING)
+ copy->value.mv_string = strdup (orig->value.mv_string);
+ else
+ copy->value = orig->value;
+
+ copy->next = md_entry_clone (orig->next);
+ return (copy);
+} /* }}} meta_entry_t *md_entry_clone */
+
static void md_entry_free (meta_entry_t *e) /* {{{ */
{
if (e == NULL)
return (md);
} /* }}} meta_data_t *meta_data_create */
+meta_data_t *meta_data_clone (meta_data_t *orig) /* {{{ */
+{
+ meta_data_t *copy;
+
+ if (orig == NULL)
+ return (NULL);
+
+ copy = meta_data_create ();
+ if (copy == NULL)
+ return (NULL);
+
+ pthread_mutex_lock (&orig->lock);
+ copy->head = md_entry_clone (orig->head);
+ pthread_mutex_unlock (&orig->lock);
+
+ return (copy);
+} /* }}} meta_data_t *meta_data_clone */
+
void meta_data_destroy (meta_data_t *md) /* {{{ */
{
if (md == NULL)
diff --git a/src/meta_data.h b/src/meta_data.h
index 9ef7b0a8ddb58cbf654cca2a3ddc1e722b2d7b2e..f1af40ee7ea5cb953e10ab5df315854bfd808a2a 100644 (file)
--- a/src/meta_data.h
+++ b/src/meta_data.h
/**
* collectd - src/meta_data.h
- * Copyright (C) 2008,2009 Florian octo Forster
+ * Copyright (C) 2008-2011 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
typedef struct meta_data_s meta_data_t;
meta_data_t *meta_data_create (void);
+meta_data_t *meta_data_clone (meta_data_t *orig);
void meta_data_destroy (meta_data_t *md);
int meta_data_exists (meta_data_t *md, const char *key);