billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=005806470af228b7efcad6ee58a8dada79b4bdab

commit 005806470af228b7efcad6ee58a8dada79b4bdab
Author: Boris Faure <bill...@gmail.com>
Date:   Wed Nov 4 22:15:59 2020 +0100

    colors: add color_scheme_dup()
---
 src/bin/colors.c | 36 ++++++++++++++++++++++++++++++++++++
 src/bin/colors.h |  4 +++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/bin/colors.c b/src/bin/colors.c
index e8d4937..acca108 100644
--- a/src/bin/colors.c
+++ b/src/bin/colors.c
@@ -793,6 +793,42 @@ end:
    return l;
 }
 
+Color_Scheme *
+color_scheme_dup(const Color_Scheme *src)
+{
+   Color_Scheme *cs;
+   size_t len_name = strlen(src->name) + 1;
+   size_t len_author = strlen(src->author) + 1;
+   size_t len_website = strlen(src->website) + 1;
+   size_t len_license = strlen(src->license) + 1;
+   size_t len = sizeof(*cs) + len_name + len_author + len_website
+      + len_license;
+   char *s;
+
+   cs = malloc(len);
+   if (!cs)
+     return NULL;
+   memcpy(cs, src, sizeof(*cs));
+   s = ((char*)cs) + sizeof(*cs);
+
+   cs->name = s;
+   memcpy(s, src->name, len_name);
+   s += len_name;
+
+   cs->author = s;
+   memcpy(s, src->author, len_author);
+   s += len_author;
+
+   cs->website = s;
+   memcpy(s, src->website, len_website);
+   s += len_website;
+
+   cs->license = s;
+   memcpy(s, src->license, len_license);
+
+   return cs;
+}
+
 void
 color_scheme_apply_from_config(Evas_Object *edje,
                                const Config *config)
diff --git a/src/bin/colors.h b/src/bin/colors.h
index 2dcdd80..6a3d238 100644
--- a/src/bin/colors.h
+++ b/src/bin/colors.h
@@ -54,7 +54,6 @@ struct _Color_Scheme
    Color_Block brightfaint;
 };
 
-
 void
 colors_term_init(Evas_Object *textgrid,
                  const Evas_Object *bg);
@@ -84,6 +83,9 @@ color_scheme_apply(Evas_Object *edje,
 Eina_List *
 color_scheme_list(void);
 
+Color_Scheme *
+color_scheme_dup(const Color_Scheme *src);
+
 void
 colors_init(void);
 

-- 


Reply via email to