[gcr] Replace g_memdup with g_memdup2



commit f6e809bc15efcf0ead351adf8e4c8e6b1a01d791
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Mon Jun 13 00:43:18 2022 +0200

    Replace g_memdup with g_memdup2

 egg/test-openssl.c           |  2 +-
 egg/test-symkey.c            |  2 +-
 gck/gck-enumerator.c         |  2 +-
 gck/gck-module.c             |  2 +-
 gck/gck-session.c            | 16 ++++++++--------
 gck/gck-slot.c               |  6 +++---
 gck/gck-uri.c                |  2 +-
 gck/test-gck-attributes.c    |  2 +-
 gcr/gcr-certificate.c        |  6 +++---
 gcr/gcr-gnupg-importer.c     |  2 +-
 gcr/gcr-key-mechanisms.c     |  2 +-
 gcr/gcr-memory-icon.c        |  2 +-
 gcr/test-certificate-chain.c |  2 +-
 13 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/egg/test-openssl.c b/egg/test-openssl.c
index b18565fe..488c5830 100644
--- a/egg/test-openssl.c
+++ b/egg/test-openssl.c
@@ -89,7 +89,7 @@ parse_reference (GQuark type,
 
        g_assert ("no data in PEM callback" && data != NULL);
        g_assert ("no data in PEM callback" && g_bytes_get_size (data) > 0);
-       test->refenc = g_memdup (g_bytes_get_data (data, NULL), g_bytes_get_size (data));
+       test->refenc = g_memdup2 (g_bytes_get_data (data, NULL), g_bytes_get_size (data));
        test->n_refenc = g_bytes_get_size (data);
 
        g_assert ("no headers present in file" && headers != NULL);
diff --git a/egg/test-symkey.c b/egg/test-symkey.c
index f363681a..f16119ff 100644
--- a/egg/test-symkey.c
+++ b/egg/test-symkey.c
@@ -380,7 +380,7 @@ test_read_cipher (gconstpointer data)
        egg_asn1x_destroy (asn);
        g_assert (ret == TRUE);
 
-       block = g_memdup (test->plain_text, test->n_text_length);
+       block = g_memdup2 (test->plain_text, test->n_text_length);
        gcry = gcry_cipher_encrypt (cih, block, test->n_text_length, NULL, 0);
        g_assert_cmpint (gcry, ==, 0);
 
diff --git a/gck/gck-enumerator.c b/gck/gck-enumerator.c
index 902e756f..97599ce2 100644
--- a/gck/gck-enumerator.c
+++ b/gck/gck-enumerator.c
@@ -888,7 +888,7 @@ gck_enumerator_set_object_type_full (GckEnumerator *self,
                self->attr_count = 0;
 
                if (attr_types) {
-                       self->attr_types = g_memdup (attr_types, sizeof (gulong) * attr_count);
+                       self->attr_types = g_memdup2 (attr_types, sizeof (gulong) * attr_count);
                        self->attr_count = attr_count;
                }
 
diff --git a/gck/gck-module.c b/gck/gck-module.c
index a3ecd46b..6f85f331 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -227,7 +227,7 @@ gck_module_info_copy (GckModuleInfo *module_info)
        if (module_info == NULL)
                return NULL;
 
-       module_info = g_memdup (module_info, sizeof (GckModuleInfo));
+       module_info = g_memdup2 (module_info, sizeof (GckModuleInfo));
        module_info->manufacturer_id = g_strdup (module_info->manufacturer_id);
        module_info->library_description = g_strdup (module_info->library_description);
        return module_info;
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 29ef89ec..031d749f 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -556,7 +556,7 @@ G_DEFINE_BOXED_TYPE (GckSessionInfo, gck_session_info,
 GckSessionInfo *
 gck_session_info_copy (GckSessionInfo *session_info)
 {
-       return g_memdup (session_info, sizeof (GckSessionInfo));
+       return g_memdup2 (session_info, sizeof (GckSessionInfo));
 }
 
 /**
@@ -958,7 +958,7 @@ gck_session_init_pin_async (GckSession *self, const guchar *pin, gsize n_pin,
        call = _gck_call_async_prep (self, perform_init_pin, NULL, sizeof (*args), free_init_pin);
        args = _gck_call_get_arguments (call);
 
-       args->pin = pin && n_pin ? g_memdup (pin, n_pin) : NULL;
+       args->pin = pin && n_pin ? g_memdup2 (pin, n_pin) : NULL;
        args->n_pin = n_pin;
 
        _gck_call_async_ready_go (call, self, cancellable, callback, user_data);
@@ -1063,9 +1063,9 @@ gck_session_set_pin_async (GckSession *self, const guchar *old_pin, gsize n_old_
        call = _gck_call_async_prep (self, perform_set_pin, NULL, sizeof (*args), free_set_pin);
        args = _gck_call_get_arguments (call);
 
-       args->old_pin = old_pin && n_old_pin ? g_memdup (old_pin, n_old_pin) : NULL;
+       args->old_pin = old_pin && n_old_pin ? g_memdup2 (old_pin, n_old_pin) : NULL;
        args->n_old_pin = n_old_pin;
-       args->new_pin = new_pin && n_new_pin ? g_memdup (new_pin, n_new_pin) : NULL;
+       args->new_pin = new_pin && n_new_pin ? g_memdup2 (new_pin, n_new_pin) : NULL;
        args->n_new_pin = n_new_pin;
 
        _gck_call_async_ready_go (call, self, cancellable, callback, user_data);
@@ -1163,7 +1163,7 @@ gck_session_login_async (GckSession *self, gulong user_type, const guchar *pin,
        args = _gck_call_get_arguments (call);
 
        args->user_type = user_type;
-       args->pin = pin && n_pin ? g_memdup (pin, n_pin) : NULL;
+       args->pin = pin && n_pin ? g_memdup2 (pin, n_pin) : NULL;
        args->n_pin = n_pin;
 
        _gck_call_async_ready_go (call, self, cancellable, callback, user_data);
@@ -2682,7 +2682,7 @@ crypt_async (GckSession *self, GckObject *key, GckMechanism *mechanism, const gu
        /* Shallow copy of the mechanism structure */
        memcpy (&args->mechanism, mechanism, sizeof (args->mechanism));
 
-       args->input = input && n_input ? g_memdup (input, n_input) : NULL;
+       args->input = input && n_input ? g_memdup2 (input, n_input) : NULL;
        args->n_input = n_input;
 
        args->init_func = init_func;
@@ -3238,9 +3238,9 @@ gck_session_verify_async (GckSession *self, GckObject *key, GckMechanism *mechan
        /* Shallow copy of the mechanism structure */
        memcpy (&args->mechanism, mechanism, sizeof (args->mechanism));
 
-       args->input = input && n_input ? g_memdup (input, n_input) : NULL;
+       args->input = input && n_input ? g_memdup2 (input, n_input) : NULL;
        args->n_input = n_input;
-       args->signature = signature && n_signature ? g_memdup (signature, n_signature) : NULL;
+       args->signature = signature && n_signature ? g_memdup2 (signature, n_signature) : NULL;
        args->n_signature = n_signature;
 
        args->key_object = g_object_ref (key);
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index b2976291..7c795cbc 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -188,7 +188,7 @@ gck_slot_info_copy (GckSlotInfo *slot_info)
        if (slot_info == NULL)
                return NULL;
 
-       slot_info = g_memdup (slot_info, sizeof (GckSlotInfo));
+       slot_info = g_memdup2 (slot_info, sizeof (GckSlotInfo));
        slot_info->manufacturer_id = g_strdup (slot_info->manufacturer_id);
        slot_info->slot_description = g_strdup (slot_info->slot_description);
 
@@ -261,7 +261,7 @@ gck_token_info_copy (GckTokenInfo *token_info)
        if (token_info == NULL)
                return NULL;
 
-       token_info = g_memdup (token_info, sizeof (GckTokenInfo));
+       token_info = g_memdup2 (token_info, sizeof (GckTokenInfo));
        token_info->label = g_strdup (token_info->label);
        token_info->manufacturer_id = g_strdup (token_info->manufacturer_id);
        token_info->model = g_strdup (token_info->model);
@@ -315,7 +315,7 @@ G_DEFINE_BOXED_TYPE (GckMechanismInfo, gck_mechanism_info,
 GckMechanismInfo *
 gck_mechanism_info_copy (GckMechanismInfo *mech_info)
 {
-       return g_memdup (mech_info, sizeof (GckMechanismInfo));
+       return g_memdup2 (mech_info, sizeof (GckMechanismInfo));
 }
 
 /**
diff --git a/gck/gck-uri.c b/gck/gck-uri.c
index e034ed5b..91ec2b56 100644
--- a/gck/gck-uri.c
+++ b/gck/gck-uri.c
@@ -270,7 +270,7 @@ gck_uri_data_copy (GckUriData *uri_data)
 {
        GckUriData *copy;
 
-       copy = g_memdup (uri_data, sizeof (GckUriData));
+       copy = g_memdup2 (uri_data, sizeof (GckUriData));
        copy->attributes = gck_attributes_ref (uri_data->attributes);
        copy->module_info = gck_module_info_copy (copy->module_info);
        copy->token_info = gck_token_info_copy (copy->token_info);
diff --git a/gck/test-gck-attributes.c b/gck/test-gck-attributes.c
index da11bf43..ab066b7b 100644
--- a/gck/test-gck-attributes.c
+++ b/gck/test-gck-attributes.c
@@ -421,7 +421,7 @@ test_build_take (void)
        const GckAttribute *attr;
        guchar *memory;
 
-       memory = g_memdup (ATTR_DATA, N_ATTR_DATA);
+       memory = g_memdup2 (ATTR_DATA, N_ATTR_DATA);
        gck_builder_take_data (&builder, ATTR_TYPE, memory, N_ATTR_DATA);
        attrs = gck_builder_end (&builder);
 
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index f3899ba5..714f4a96 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -529,7 +529,7 @@ gcr_certificate_get_issuer_raw (GcrCertificate *self,
        }
 
        *n_data = g_bytes_get_size (bytes);
-       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
+       result = g_memdup2 (g_bytes_get_data (bytes, NULL), *n_data);
        g_bytes_unref (bytes);
 
        return result;
@@ -741,7 +741,7 @@ gcr_certificate_get_subject_raw (GcrCertificate *self, gsize *n_data)
        }
 
        *n_data = g_bytes_get_size (bytes);
-       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
+       result = g_memdup2 (g_bytes_get_data (bytes, NULL), *n_data);
 
        g_bytes_unref (bytes);
 
@@ -952,7 +952,7 @@ gcr_certificate_get_serial_number (GcrCertificate *self, gsize *n_length)
        g_return_val_if_fail (bytes != NULL, NULL);
 
        *n_length = g_bytes_get_size (bytes);
-       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_length);
+       result = g_memdup2 (g_bytes_get_data (bytes, NULL), *n_length);
 
        g_bytes_unref (bytes);
        return result;
diff --git a/gcr/gcr-gnupg-importer.c b/gcr/gcr-gnupg-importer.c
index 63b7b587..5fa93bdc 100644
--- a/gcr/gcr-gnupg-importer.c
+++ b/gcr/gcr-gnupg-importer.c
@@ -285,7 +285,7 @@ _gcr_gnupg_importer_queue_for_parsed (GcrImporter *importer,
        block = gcr_parsed_get_data (parsed, &n_block);
        g_return_val_if_fail (block, FALSE);
 
-       g_memory_input_stream_add_data (self->pv->packets, g_memdup (block, n_block),
+       g_memory_input_stream_add_data (self->pv->packets, g_memdup2 (block, n_block),
                                        n_block, g_free);
        return TRUE;
 }
diff --git a/gcr/gcr-key-mechanisms.c b/gcr/gcr-key-mechanisms.c
index 89f968aa..1f60ba82 100644
--- a/gcr/gcr-key-mechanisms.c
+++ b/gcr/gcr-key-mechanisms.c
@@ -165,7 +165,7 @@ _gcr_key_mechanisms_check_async (GckObject *key,
        task = g_task_new (key, cancellable, callback, user_data);
        g_task_set_source_tag (task, _gcr_key_mechanisms_check_async);
        closure = g_new0 (CheckClosure, 1);
-       closure->mechanisms = g_memdup (mechanisms, n_mechanisms * sizeof (gulong));
+       closure->mechanisms = g_memdup2 (mechanisms, n_mechanisms * sizeof (gulong));
        closure->n_mechanisms = n_mechanisms;
        closure->action_attr_type = action_attr_type;
        g_task_set_task_data (task, closure, check_closure_free);
diff --git a/gcr/gcr-memory-icon.c b/gcr/gcr-memory-icon.c
index 40a45276..b37f9a50 100644
--- a/gcr/gcr-memory-icon.c
+++ b/gcr/gcr-memory-icon.c
@@ -184,7 +184,7 @@ _gcr_memory_icon_new (const gchar *image_type, gconstpointer data, gsize n_data)
        g_return_val_if_fail (data != NULL, NULL);
        g_return_val_if_fail (n_data != 0, NULL);
 
-       return _gcr_memory_icon_new_full (image_type, g_memdup (data, n_data),
+       return _gcr_memory_icon_new_full (image_type, g_memdup2 (data, n_data),
                                          n_data, 0, g_free);
 }
 
diff --git a/gcr/test-certificate-chain.c b/gcr/test-certificate-chain.c
index 6cb8ee49..0d8d07f5 100644
--- a/gcr/test-certificate-chain.c
+++ b/gcr/test-certificate-chain.c
@@ -109,7 +109,7 @@ static GcrCertificate*
 mock_certificate_new (gconstpointer data, gsize n_data)
 {
        MockCertificate *self = g_object_new (mock_certificate_get_type (), NULL);
-       self->data = g_memdup (data, n_data);
+       self->data = g_memdup2 (data, n_data);
        self->n_data = n_data;
        g_assert (self->created_on == g_thread_self ());
        return GCR_CERTIFICATE (self);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]