[lttng-dev] [PATCH babeltrace] Fix: Use of functions not provided by glib 2.22

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Nov 12 14:35:34 EST 2013


Merged, thanks!

Mathieu

----- Original Message -----
> From: "Jérémie Galarneau" <jeremie.galarneau at efficios.com>
> To: lttng-dev at lists.lttng.org
> Sent: Monday, November 11, 2013 11:16:41 AM
> Subject: [lttng-dev] [PATCH babeltrace] Fix: Use of functions not provided	by glib 2.22
> 
> Signed-off-by: Jérémie Galarneau <jeremie.galarneau at efficios.com>
> ---
>  formats/ctf/writer/event-fields.c | 10 ++++++----
>  formats/ctf/writer/event-types.c  |  4 ++--
>  formats/ctf/writer/writer.c       | 11 +++++++----
>  3 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/formats/ctf/writer/event-fields.c
> b/formats/ctf/writer/event-fields.c
> index aa389fd..30fe578 100644
> --- a/formats/ctf/writer/event-fields.c
> +++ b/formats/ctf/writer/event-fields.c
> @@ -247,13 +247,14 @@ int bt_ctf_field_sequence_set_length(struct
> bt_ctf_field *field,
>  		bt_ctf_field_put(sequence->length);
>  	}
>  
> -	sequence->elements = g_ptr_array_new_full((size_t)sequence_length,
> -		(GDestroyNotify)bt_ctf_field_put);
> +	sequence->elements = g_ptr_array_sized_new((size_t)sequence_length);
>  	if (!sequence->elements) {
>  		ret = -1;
>  		goto end;
>  	}
>  
> +	g_ptr_array_set_free_func(sequence->elements,
> +		(GDestroyNotify)bt_ctf_field_put);
>  	g_ptr_array_set_size(sequence->elements, (size_t)sequence_length);
>  	bt_ctf_field_get(length_field);
>  	sequence->length = length_field;
> @@ -768,12 +769,13 @@ struct bt_ctf_field *bt_ctf_field_array_create(struct
> bt_ctf_field_type *type)
>  
>  	array_type = container_of(type, struct bt_ctf_field_type_array, parent);
>  	array_length = array_type->length;
> -	array->elements = g_ptr_array_new_full(array_length,
> -		(GDestroyNotify)bt_ctf_field_put);
> +	array->elements = g_ptr_array_sized_new(array_length);
>  	if (!array->elements) {
>  		goto error;
>  	}
>  
> +	g_ptr_array_set_free_func(array->elements,
> +		(GDestroyNotify)bt_ctf_field_put);
>  	g_ptr_array_set_size(array->elements, array_length);
>  	return &array->parent;
>  error:
> diff --git a/formats/ctf/writer/event-types.c
> b/formats/ctf/writer/event-types.c
> index 091b320..fa4e713 100644
> --- a/formats/ctf/writer/event-types.c
> +++ b/formats/ctf/writer/event-types.c
> @@ -214,8 +214,8 @@ int add_structure_field(GPtrArray *fields,
>  	struct structure_field *field;
>  
>  	/* Make sure structure does not contain a field of the same name */
> -	if (g_hash_table_contains(field_name_to_index,
> -			GUINT_TO_POINTER(name_quark))) {
> +	if (g_hash_table_lookup_extended(field_name_to_index,
> +		GUINT_TO_POINTER(name_quark), NULL, NULL)) {
>  		ret = -1;
>  		goto end;
>  	}
> diff --git a/formats/ctf/writer/writer.c b/formats/ctf/writer/writer.c
> index 5600a92..a3ca263 100644
> --- a/formats/ctf/writer/writer.c
> +++ b/formats/ctf/writer/writer.c
> @@ -560,8 +560,9 @@ int validate_identifier(const char *input_string)
>  
>  	token = strtok_r(string, " ", &save_ptr);
>  	while (token) {
> -		if (g_hash_table_contains(reserved_keywords_set,
> -			GINT_TO_POINTER(g_quark_from_string(token)))) {
> +		if (g_hash_table_lookup_extended(reserved_keywords_set,
> +			GINT_TO_POINTER(g_quark_from_string(token)),
> +			NULL, NULL)) {
>  			ret = -1;
>  			goto end;
>  		}
> @@ -737,8 +738,10 @@ void writer_init(void)
>  
>  	reserved_keywords_set = g_hash_table_new(g_direct_hash, g_direct_equal);
>  	for (i = 0; i < reserved_keywords_count; i++) {
> -		g_hash_table_add(reserved_keywords_set,
> -		GINT_TO_POINTER(g_quark_from_string(reserved_keywords_str[i])));
> +		gpointer quark = GINT_TO_POINTER(g_quark_from_string(
> +			reserved_keywords_str[i]));
> +
> +		g_hash_table_insert(reserved_keywords_set, quark, quark);
>  	}
>  
>  	init_done = 1;
> --
> 1.8.4.2
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list