Changeset 965 for trunk/psLib/src/collections/psBitSet.c
- Timestamp:
- Jun 9, 2004, 2:29:09 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psBitSet.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psBitSet.c
r952 r965 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06- 09 21:18:24$12 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-10 00:29:09 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 #include <stdio.h> 23 23 #include <ctype.h> 24 #include <math.h> 24 25 25 26 #include "psBitSet.h" … … 77 78 psBitSet* psBitSetAlloc(int n) 78 79 { 80 int numBytes = 0; 79 81 psBitSet *newObj = NULL; 80 82 … … 84 86 } 85 87 88 numBytes = ceil(n/8.0); 86 89 newObj = psAlloc(sizeof(psBitSet)); 87 newObj->n = n ;90 newObj->n = numBytes; 88 91 89 92 // Ignore splint warning about releasing pointer members, since they've not been allocated yet 90 93 /*@i@*/ 91 newObj->bits = psAlloc(sizeof(char)*n );92 memset(newObj->bits, n , 0);94 newObj->bits = psAlloc(sizeof(char)*numBytes); 95 memset(newObj->bits, numBytes, 0); 93 96 94 97 return newObj; … … 113 116 return inBitSet; 114 117 } else if(bit < 0) { 115 psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit); 118 psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit); 119 return inBitSet; 120 } else if(bit > inBitSet->n*8-1) { 121 psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit); 116 122 return inBitSet; 117 123 } … … 132 138 return 0; 133 139 } else if(bit < 0) { 134 psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit); 140 psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit); 141 return 0; 142 } else if(bit > inBitSet->n*8-1) { 143 psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit); 135 144 return 0; 136 145 }
Note:
See TracChangeset
for help on using the changeset viewer.
