]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Add ssl_iostream_settings_init_from()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 Oct 2017 14:54:34 +0000 (16:54 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 6 Nov 2017 23:09:00 +0000 (01:09 +0200)
This allows duplicating settings to an already existing struct without
having to allocate it.

src/lib-ssl-iostream/iostream-ssl.c
src/lib-ssl-iostream/iostream-ssl.h

index ceaec061fa04aa43f39080541d9ab66aeeb1167c..66027565a9bcd0de111557d0e5323d7f217816eb 100644 (file)
@@ -215,15 +215,21 @@ const char *ssl_iostream_get_last_error(struct ssl_iostream *ssl_io)
        return ssl_vfuncs->get_last_error(ssl_io);
 }
 
-struct ssl_iostream_settings *
-ssl_iostream_settings_dup(pool_t pool,
-                         const struct ssl_iostream_settings *old_set)
+struct ssl_iostream_settings *ssl_iostream_settings_dup(pool_t pool,
+                       const struct ssl_iostream_settings *old_set)
 {
        struct ssl_iostream_settings *new_set;
 
        new_set = p_new(pool, struct ssl_iostream_settings, 1);
-       memcpy(new_set, old_set, sizeof(*new_set));
+       ssl_iostream_settings_init_from(pool, new_set, old_set);
+       return new_set;
+}
 
+void ssl_iostream_settings_init_from(pool_t pool,
+                                    struct ssl_iostream_settings *new_set,
+                                    const struct ssl_iostream_settings *old_set)
+{
+       memcpy(new_set, old_set, sizeof(*new_set));
        new_set->protocols = p_strdup(pool, old_set->protocols);
        new_set->cipher_list = p_strdup(pool, old_set->cipher_list);
        new_set->curve_list = p_strdup(pool, old_set->curve_list);
@@ -239,6 +245,4 @@ ssl_iostream_settings_dup(pool_t pool,
        new_set->dh = p_strdup(pool, old_set->dh);
        new_set->cert_username_field = p_strdup(pool, old_set->cert_username_field);
        new_set->crypto_device = p_strdup(pool, old_set->crypto_device);
-
-       return new_set;
 }
index bdc9dfea1475aa7ea92476a03cb2a99c10f88436..4de49ba19766bd9f85115501918fc5e033139473 100644 (file)
@@ -91,7 +91,11 @@ int ssl_iostream_context_init_server(const struct ssl_iostream_settings *set,
                                     struct ssl_iostream_context **ctx_r,
                                     const char **error_r);
 void ssl_iostream_context_deinit(struct ssl_iostream_context **ctx);
+
 struct ssl_iostream_settings *ssl_iostream_settings_dup(pool_t pool,
                        const struct ssl_iostream_settings *old_set);
+void ssl_iostream_settings_init_from(pool_t pool,
+                                    struct ssl_iostream_settings *new_set,
+                                    const struct ssl_iostream_settings *old_set);
 
 #endif