/[global]/global/libutil/idset.c
ViewVC logotype

Diff of /global/libutil/idset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by shigio, Fri Jul 29 13:33:14 2005 UTC revision 1.5 by shigio, Tue Oct 4 07:59:04 2005 UTC
# Line 53  idset_close(idset)             [] Line 53  idset_close(idset)             []
53   * Allocate memory for new idset.   * Allocate memory for new idset.
54   */   */
55  IDSET *  IDSET *
56  idset_open(size)  idset_open(unsigned int size)
         unsigned int size;  
57  {  {
58          IDSET *idset = malloc(sizeof(IDSET));          IDSET *idset = malloc(sizeof(IDSET));
59    
# Line 74  idset_open(size) Line 73  idset_open(size)
73   *      i)      id      id number   *      i)      id      id number
74   */   */
75  void  void
76  idset_add(idset, id)  idset_add(IDSET *idset, unsigned int id)
         IDSET *idset;  
         unsigned int id;  
77  {  {
78          if (id >= idset->size)          if (id >= idset->size)
79                  die("idset_add: id is out of range.");                  die("idset_add: id is out of range.");
# Line 92  idset_add(idset, id) Line 89  idset_add(idset, id)
89   *      r)              true: contains, false: doesn't contain   *      r)              true: contains, false: doesn't contain
90   */   */
91  int  int
92  idset_contains(idset, id)  idset_contains(IDSET *idset, unsigned int id)
         IDSET *idset;  
         unsigned int id;  
93  {  {
94          return (id >= idset->max) ? 0 :          return (id >= idset->max) ? 0 :
95                          (idset->set[id / CHAR_BIT] & (1 << (id % CHAR_BIT)));                          (idset->set[id / CHAR_BIT] & (1 << (id % CHAR_BIT)));
# Line 106  idset_contains(idset, id) Line 101  idset_contains(idset, id)
101   *      r)              number of bits   *      r)              number of bits
102   */   */
103  int  int
104  idset_count(idset)  idset_count(IDSET *idset)
         IDSET *idset;  
105  {  {
106          int id, count = 0;          int id, count = 0;
107    
# Line 120  idset_count(idset) Line 114  idset_count(idset)
114   * Free memory for the idset.   * Free memory for the idset.
115   */   */
116  void  void
117  idset_close(idset)  idset_close(IDSET *idset)
         IDSET *idset;  
118  {  {
119          free(idset->set);          free(idset->set);
120          free(idset);          free(idset);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26