mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* st.c (st_update): pass pointer to key to the callback function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6da92c3e89
commit
28cc4f7543
7 changed files with 16 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Mar 29 23:50:15 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* st.c (st_update): pass pointer to key to the callback function.
|
||||||
|
|
||||||
Thu Mar 29 16:36:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Mar 29 16:36:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* st.c (st_update): add existing parameter to the callback function.
|
* st.c (st_update): add existing parameter to the callback function.
|
||||||
|
|
|
@ -60,9 +60,9 @@ numhash_each(VALUE self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
update_func(st_data_t key, st_data_t *value, st_data_t arg)
|
update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
VALUE ret = rb_yield_values(2, (VALUE)key, (VALUE)*value);
|
VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case Qfalse:
|
case Qfalse:
|
||||||
return ST_STOP;
|
return ST_STOP;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#include <ruby/st.h>
|
#include <ruby/st.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
update_func(st_data_t key, st_data_t *value, st_data_t arg, int existing)
|
update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)key, (VALUE)*value);
|
VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case Qfalse:
|
case Qfalse:
|
||||||
return ST_STOP;
|
return ST_STOP;
|
||||||
|
|
5
gc.c
5
gc.c
|
@ -3672,10 +3672,11 @@ wmap_allocate(VALUE klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wmap_final_func(st_data_t key, st_data_t *value, st_data_t arg, int existing)
|
wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
VALUE obj = (VALUE)key, ary = (VALUE)*value;
|
VALUE obj, ary;
|
||||||
if (!existing) return ST_STOP;
|
if (!existing) return ST_STOP;
|
||||||
|
obj = (VALUE)*key, ary = (VALUE)*value;
|
||||||
rb_ary_delete(ary, obj);
|
rb_ary_delete(ary, obj);
|
||||||
if (!RARRAY_LEN(ary)) return ST_DELETE;
|
if (!RARRAY_LEN(ary)) return ST_DELETE;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
|
|
|
@ -121,7 +121,7 @@ int st_insert(st_table *, st_data_t, st_data_t);
|
||||||
int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
|
int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
|
||||||
int st_lookup(st_table *, st_data_t, st_data_t *);
|
int st_lookup(st_table *, st_data_t, st_data_t *);
|
||||||
int st_get_key(st_table *, st_data_t, st_data_t *);
|
int st_get_key(st_table *, st_data_t, st_data_t *);
|
||||||
typedef int st_update_callback_func(st_data_t key, st_data_t *value, st_data_t arg, int existing);
|
typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
|
||||||
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
|
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
|
||||||
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
||||||
int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
|
int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
|
||||||
|
|
4
load.c
4
load.c
|
@ -417,7 +417,7 @@ load_lock(const char *ftptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
release_barrier(st_data_t key, st_data_t *value, st_data_t done, int existing)
|
release_barrier(st_data_t *key, st_data_t *value, st_data_t done, int existing)
|
||||||
{
|
{
|
||||||
VALUE barrier = (VALUE)*value;
|
VALUE barrier = (VALUE)*value;
|
||||||
if (!existing) return ST_STOP;
|
if (!existing) return ST_STOP;
|
||||||
|
@ -425,7 +425,7 @@ release_barrier(st_data_t key, st_data_t *value, st_data_t done, int existing)
|
||||||
/* still in-use */
|
/* still in-use */
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
xfree((char *)key);
|
xfree((char *)*key);
|
||||||
return ST_DELETE;
|
return ST_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
st.c
4
st.c
|
@ -841,7 +841,7 @@ st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data
|
||||||
existing = 1;
|
existing = 1;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
retval = (*func)(key, &value, arg, existing);
|
retval = (*func)(&key, &value, arg, existing);
|
||||||
if (!table->entries_packed) {
|
if (!table->entries_packed) {
|
||||||
FIND_ENTRY(table, ptr, hash_val, bin_pos);
|
FIND_ENTRY(table, ptr, hash_val, bin_pos);
|
||||||
goto unpacked;
|
goto unpacked;
|
||||||
|
@ -869,7 +869,7 @@ st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data
|
||||||
existing = 1;
|
existing = 1;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
retval = (*func)(ptr->key, &value, arg, existing);
|
retval = (*func)(&key, &value, arg, existing);
|
||||||
unpacked:
|
unpacked:
|
||||||
switch (retval) {
|
switch (retval) {
|
||||||
case ST_CONTINUE:
|
case ST_CONTINUE:
|
||||||
|
|
Loading…
Reference in a new issue