Commit 88e84f52 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik
Browse files

wrote a comment describing why a hash node's key should not also get

Mon Jun  1 04:43:27 1998  Tim Janik  <timj@gtk.org>

        * ghash.c (g_hash_table_insert): wrote a comment describing why
        a hash node's key should not also get replaced when overriding
        previous entries.

Tue May 26 18:30:06 1998  Tim Janik  <timj@gtk.org>

        * glib.h (g_string_sized_new): new function to controll the preallocated
        size of a GString.

        * glib.h (g_strreversed): new function to reverse a string.
parent 8a6a8c7b
Mon Jun 1 04:43:27 1998 Tim Janik <timj@gtk.org>
* ghash.c (g_hash_table_insert): wrote a comment describing why
a hash node's key should not also get replaced when overriding
previous entries.
Tue May 26 18:30:06 1998 Tim Janik <timj@gtk.org>
* glib.h (g_string_sized_new): new function to controll the preallocated
size of a GString.
* glib.h (g_strreversed): new function to reverse a string.
Mon May 18 22:14:39 1998 Owen Taylor <otaylor@gtk.org>
(Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp> : gtk-joke-980517-0.patch)
......
......@@ -122,6 +122,13 @@ g_hash_table_insert (GHashTable *hash_table,
(* rhash_table->key_compare_func) (node->key, key)) ||
(node->key == key))
{
/* do not reset node->key in this place, keeping
* the old key might be intended.
* a g_hash_table_remove/g_hash_table_insert pair
* can be used otherwise.
*
* node->key = key;
*/
node->value = value;
return;
}
......
......@@ -752,6 +752,7 @@ gint g_strcasecmp (const gchar *s1,
const gchar *s2);
void g_strdown (gchar *string);
void g_strup (gchar *string);
void g_strreverse (gchar *string);
guint g_parse_debug_string (const gchar *string,
GDebugKey *keys,
guint nkeys);
......@@ -795,6 +796,7 @@ gchar* g_string_chunk_insert_const (GStringChunk *chunk,
/* Strings
*/
GString* g_string_new (const gchar *init);
GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gint free_segment);
GString* g_string_assign (GString *lval,
......@@ -1060,6 +1062,8 @@ void g_scanner_foreach_symbol (GScanner *scanner,
gpointer func_data);
void g_scanner_remove_symbol (GScanner *scanner,
const gchar *symbol);
void g_scanner_freeze_symbol_table (GScanner *scanner);
void g_scanner_thaw_symbol_table (GScanner *scanner);
void g_scanner_unexp_token (GScanner *scanner,
GTokenType expected_token,
const gchar *identifier_spec,
......
......@@ -347,8 +347,8 @@ g_scanner_add_symbol (GScanner *scanner,
{
register GScannerHashVal *hash_val;
g_return_if_fail (symbol != NULL);
g_return_if_fail (scanner != NULL);
g_return_if_fail (symbol != NULL);
hash_val = g_scanner_lookup_internal (scanner, symbol);
......@@ -429,6 +429,8 @@ g_scanner_remove_symbol (GScanner *scanner,
{
register GScannerHashVal *hash_val;
g_return_if_fail (scanner != NULL);
hash_val = g_scanner_lookup_internal (scanner, symbol);
if (hash_val)
......@@ -439,6 +441,22 @@ g_scanner_remove_symbol (GScanner *scanner,
}
}
void
g_scanner_freeze_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
g_hash_table_freeze (scanner->symbol_table);
}
void
g_scanner_thaw_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
g_hash_table_thaw (scanner->symbol_table);
}
GTokenType
g_scanner_peek_next_token (GScanner *scanner)
{
......
......@@ -205,7 +205,7 @@ g_string_maybe_expand (GRealString* string, gint len)
}
GString*
g_string_new (const gchar *init)
g_string_sized_new (guint dfl_size)
{
GRealString *string;
......@@ -216,16 +216,29 @@ g_string_new (const gchar *init)
string = g_chunk_new (GRealString, string_mem_chunk);
string->alloc = 2;
string->alloc = 0;
string->len = 0;
string->str = g_new0(char, 2);
string->str = NULL;
if (init)
g_string_append ((GString*)string, init);
g_string_maybe_expand (string, MAX (dfl_size, 2));
string->str[0] = 0;
return (GString*) string;
}
GString*
g_string_new (const gchar *init)
{
GString *string;
string = g_string_sized_new (2);
if (init)
g_string_append (string, init);
return string;
}
void
g_string_free (GString *string,
gint free_segment)
......
......@@ -731,6 +731,31 @@ g_strup (gchar *string)
}
}
void
g_strreverse (gchar *string)
{
g_return_if_fail (string != NULL);
if (*string)
{
register gchar *h, *t;
h = string;
t = string + strlen (string) - 1;
while (h < t)
{
register gchar c;
c = *h;
*h = *t;
h++;
*t = c;
t--;
}
}
}
gint
g_strcasecmp (const gchar *s1,
const gchar *s2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment