*
* @author Philip Levis
* @author Kyle Jamieson
+ * @author Geoffrey Mainland
* @date $Date$
*/
pool_t* rval = queue[index];
queue[index] = NULL;
free--;
- index = (index + 1) % size;
+ index++;
+ if (index == size) {
+ index = 0;
+ }
return rval;
}
return NULL;
return FAIL;
}
else {
- uint8_t emptyIndex = (index + free) % size;
+ uint8_t emptyIndex = (index + free);
+ if (emptyIndex >= size) {
+ emptyIndex -= size;
+ }
queue[emptyIndex] = newVal;
free++;
return SUCCESS;