diff options
author | Bruno Haible <bruno@clisp.org> | 2008-02-10 19:35:54 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2008-02-10 19:35:54 +0100 |
commit | 92877a2d8aef6f0296ff0567f9828151d4d82d64 (patch) | |
tree | 352a02dd001f6ffb4134396bf36ea32e853e1cf3 /lib/gl_carray_list.c | |
parent | 506bbd4259b25b0fa7532ccf144d9441324dbfca (diff) | |
download | gnulib-92877a2d8aef6f0296ff0567f9828151d4d82d64.tar.gz |
New abstract list operation 'node_set_value'.
Diffstat (limited to 'lib/gl_carray_list.c')
-rw-r--r-- | lib/gl_carray_list.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/gl_carray_list.c b/lib/gl_carray_list.c index 8e0c7d6ed1..8b43901e2b 100644 --- a/lib/gl_carray_list.c +++ b/lib/gl_carray_list.c @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a circular array. - Copyright (C) 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2006. This program is free software: you can redistribute it and/or modify @@ -126,6 +126,21 @@ gl_carray_node_value (gl_list_t list, gl_list_node_t node) return list->elements[i]; } +static void +gl_carray_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt) +{ + uintptr_t index = NODE_TO_INDEX (node); + size_t i; + + if (!(index < list->count)) + /* Invalid argument. */ + abort (); + i = list->offset + index; + if (i >= list->allocated) + i -= list->allocated; + list->elements[i] = elt; +} + static gl_list_node_t gl_carray_next_node (gl_list_t list, gl_list_node_t node) { @@ -808,6 +823,7 @@ const struct gl_list_implementation gl_carray_list_implementation = gl_carray_create, gl_carray_size, gl_carray_node_value, + gl_carray_node_set_value, gl_carray_next_node, gl_carray_previous_node, gl_carray_get_at, |