mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-11 11:44:03 +02:00
Avoid an unnecessary strlen if len is -1. (#169692, Benoit Dejean)
2005-07-19 Matthias Clasen <mclasen@redhat.com> * glib/gstring.c (g_string_chunk_insert_len): Avoid an unnecessary strlen if len is -1. (#169692, Benoit Dejean)
This commit is contained in:
committed by
Matthias Clasen
parent
e2f521eb19
commit
912e4ea3cb
@@ -1,5 +1,9 @@
|
|||||||
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_chunk_insert_len): Avoid
|
||||||
|
an unnecessary strlen if len is -1. (#169692,
|
||||||
|
Benoit Dejean)
|
||||||
|
|
||||||
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
||||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||||
(#167572, Gert Doering)
|
(#167572, Gert Doering)
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_chunk_insert_len): Avoid
|
||||||
|
an unnecessary strlen if len is -1. (#169692,
|
||||||
|
Benoit Dejean)
|
||||||
|
|
||||||
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
||||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||||
(#167572, Gert Doering)
|
(#167572, Gert Doering)
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_chunk_insert_len): Avoid
|
||||||
|
an unnecessary strlen if len is -1. (#169692,
|
||||||
|
Benoit Dejean)
|
||||||
|
|
||||||
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
||||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||||
(#167572, Gert Doering)
|
(#167572, Gert Doering)
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
2005-07-19 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gstring.c (g_string_chunk_insert_len): Avoid
|
||||||
|
an unnecessary strlen if len is -1. (#169692,
|
||||||
|
Benoit Dejean)
|
||||||
|
|
||||||
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
* glib/gatomic.c (g_atomic_pointer_compare_and_exchange):
|
||||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||||
(#167572, Gert Doering)
|
(#167572, Gert Doering)
|
||||||
|
@@ -218,16 +218,19 @@ g_string_chunk_insert_len (GStringChunk *chunk,
|
|||||||
const gchar *string,
|
const gchar *string,
|
||||||
gssize len)
|
gssize len)
|
||||||
{
|
{
|
||||||
|
gssize size;
|
||||||
gchar* pos;
|
gchar* pos;
|
||||||
|
|
||||||
g_return_val_if_fail (chunk != NULL, NULL);
|
g_return_val_if_fail (chunk != NULL, NULL);
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen (string);
|
size = strlen (string);
|
||||||
|
else
|
||||||
|
size = len;
|
||||||
|
|
||||||
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
if ((chunk->storage_next + size + 1) > chunk->this_size)
|
||||||
{
|
{
|
||||||
gsize new_size = nearest_power (chunk->default_size, len + 1);
|
gsize new_size = nearest_power (chunk->default_size, size + 1);
|
||||||
|
|
||||||
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
||||||
g_new (gchar, new_size));
|
g_new (gchar, new_size));
|
||||||
@@ -238,12 +241,13 @@ g_string_chunk_insert_len (GStringChunk *chunk,
|
|||||||
|
|
||||||
pos = ((gchar *) chunk->storage_list->data) + chunk->storage_next;
|
pos = ((gchar *) chunk->storage_list->data) + chunk->storage_next;
|
||||||
|
|
||||||
*(pos + len) = '\0';
|
*(pos + size) = '\0';
|
||||||
|
|
||||||
strncpy (pos, string, len);
|
strncpy (pos, string, size);
|
||||||
len = strlen (pos);
|
if (len > 0)
|
||||||
|
size = strlen (pos);
|
||||||
|
|
||||||
chunk->storage_next += len + 1;
|
chunk->storage_next += size + 1;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user