mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01: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:
parent
e2f521eb19
commit
912e4ea3cb
@ -1,5 +1,9 @@
|
||||
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):
|
||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||
(#167572, Gert Doering)
|
||||
|
@ -1,5 +1,9 @@
|
||||
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):
|
||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||
(#167572, Gert Doering)
|
||||
|
@ -1,5 +1,9 @@
|
||||
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):
|
||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||
(#167572, Gert Doering)
|
||||
|
@ -1,5 +1,9 @@
|
||||
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):
|
||||
Fix g_atomic_pointer_compare_and_exchange on sparc64.
|
||||
(#167572, Gert Doering)
|
||||
|
@ -218,16 +218,19 @@ g_string_chunk_insert_len (GStringChunk *chunk,
|
||||
const gchar *string,
|
||||
gssize len)
|
||||
{
|
||||
gssize size;
|
||||
gchar* pos;
|
||||
|
||||
g_return_val_if_fail (chunk != NULL, NULL);
|
||||
|
||||
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,
|
||||
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 + len) = '\0';
|
||||
*(pos + size) = '\0';
|
||||
|
||||
strncpy (pos, string, len);
|
||||
len = strlen (pos);
|
||||
strncpy (pos, string, size);
|
||||
if (len > 0)
|
||||
size = strlen (pos);
|
||||
|
||||
chunk->storage_next += len + 1;
|
||||
chunk->storage_next += size + 1;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user