From 071677ee93e42c3097f1c3acb5ad7fc73eaf2509 Mon Sep 17 00:00:00 2001
From: "Alexander V. Chernikov" <melifaro@ipfw.ru>
Date: Fri, 13 Feb 2015 13:11:07 +0300
Subject: [PATCH 6/8] * Pass struct config to cfg_copy_list to specify where to
 alloc memory * from

---
 conf/conf.c       | 4 ++--
 conf/conf.h       | 2 +-
 nest/rt-dev.c     | 2 +-
 proto/radv/radv.c | 2 +-
 sysdep/unix/krt.c | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/conf/conf.c b/conf/conf.c
index 9f93813..fd619f9 100644
--- a/conf/conf.c
+++ b/conf/conf.c
@@ -547,14 +547,14 @@ cfg_strdup(struct config *c, char *str)
 
 
 void
-cfg_copy_list(list *dest, list *src, unsigned node_size)
+cfg_copy_list(struct config *c, list *dest, list *src, unsigned node_size)
 {
   node *dn, *sn;
 
   init_list(dest);
   WALK_LIST(sn, *src)
   {
-    dn = cfg_alloc(node_size);
+    dn = cfl_alloc(c, node_size);
     memcpy(dn, sn, node_size);
     add_tail(dest, dn);
   }
diff --git a/conf/conf.h b/conf/conf.h
index eb8acb5..71da2a1 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -93,7 +93,7 @@ extern linpool *cfg_mem;
 #define cfg_allocu(size) lp_allocu(cfg_mem, size)
 #define cfg_allocz(size) lp_allocz(cfg_mem, size)
 char *cfg_strdup(struct config *c, char *str);
-void cfg_copy_list(list *dest, list *src, unsigned node_size);
+void cfg_copy_list(struct config *c, list *dest, list *src, unsigned node_size);
 struct config * config_get_ptr_new(void);
 
 #define cfl_alloc(c, size) lp_alloc((c)->mem, size)
diff --git a/nest/rt-dev.c b/nest/rt-dev.c
index 5d22396..c153c3f 100644
--- a/nest/rt-dev.c
+++ b/nest/rt-dev.c
@@ -108,7 +108,7 @@ dev_copy_config(struct proto_config *dest, struct proto_config *src)
    * Copy suffices to be is shallow, because new nodes can be added, but
    * old nodes cannot be modified (although they contain internal lists).
    */
-  cfg_copy_list(&d->iface_list, &s->iface_list, sizeof(struct iface_patt));
+  cfg_copy_list(dest->global, &d->iface_list, &s->iface_list, sizeof(struct iface_patt));
 }
 
 struct protocol proto_device = {
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index eb2a693..d1bed6e 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -411,7 +411,7 @@ radv_copy_config(struct proto_config *dest, struct proto_config *src)
   init_list(&d->patt_list);
 
   /* We copy pref_list, shallow copy suffices */
-  cfg_copy_list(&d->pref_list, &s->pref_list, sizeof(struct radv_prefix_config));
+  cfg_copy_list(dest->global, &d->pref_list, &s->pref_list, sizeof(struct radv_prefix_config));
 }
 
 static void
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index d342f7b..ded42c7 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -269,7 +269,7 @@ kif_copy_config(struct proto_config *dest, struct proto_config *src)
   proto_copy_rest(dest, src, sizeof(struct kif_config));
 
   /* Copy primary addr list */
-  cfg_copy_list(&d->primary, &s->primary, sizeof(struct kif_primary_item));
+  cfg_copy_list(dest->global, &d->primary, &s->primary, sizeof(struct kif_primary_item));
 
   /* Fix sysdep parts */
   kif_sys_copy_config(d, s);
-- 
2.1.2

