Skip to content

Commit

Permalink
valueCellIndex() return size_t type
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 9, 2024
1 parent 8374343 commit a9c4868
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static void GraphMeterMode_reallocateGraphBuffer(Meter* this, const GraphDrawCon
data->nValues = nValues;
}

static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool isPercentChart, int deltaExp, unsigned int y, unsigned int* scaleFactor, unsigned int* increment) {
static size_t GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool isPercentChart, int deltaExp, unsigned int y, unsigned int* scaleFactor, unsigned int* increment) {
if (scaleFactor)
*scaleFactor = 1;

Expand All @@ -334,7 +334,7 @@ static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool
*increment = 1;

if (y > yTop)
return (unsigned int)-1;
return (size_t)-1;

return y;
}
Expand All @@ -359,7 +359,7 @@ static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool
*increment = 2U << deltaExp;

if (y > yTop)
return (unsigned int)-1;
return (size_t)-1;

// "b" is the "base" offset or the upper bits of offset
unsigned int b = (y * 2) << deltaExp;
Expand Down Expand Up @@ -600,7 +600,7 @@ static void GraphMeterMode_computeColors(Meter* this, const GraphDrawContext* co
assert((unsigned int)numDots <= graphHeight * 8);

unsigned int increment;
unsigned int firstCellIndex = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExp, 0, NULL, &increment);
size_t firstCellIndex = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExp, 0, NULL, &increment);
assert(firstCellIndex < context->nCellsPerValue);

unsigned int topCell = ((unsigned int)numDots - 1) / 8;
Expand Down Expand Up @@ -913,9 +913,9 @@ static void GraphMeterMode_recordNewValue(Meter* this, const GraphDrawContext* c
}

// Clear cells
unsigned int i = ((unsigned int)numDots + 8 - 1) / 8; // Round up
i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, 0, i, NULL, NULL);
if (i != (unsigned int)-1) {
unsigned int y = ((unsigned int)numDots + 8 - 1) / 8; // Round up
size_t i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, 0, y, NULL, NULL);
if (i != (size_t)-1) {
assert(i < nCellsPerValue);
memset(&valueStart[i], 0, (nCellsPerValue - i) * sizeof(*valueStart));
}
Expand Down Expand Up @@ -1048,8 +1048,8 @@ static int GraphMeterMode_lookupCell(const Meter* this, const GraphDrawContext*
int deltaExpArg = deltaExp >= UINT16_WIDTH ? UINT16_WIDTH - 1 : deltaExp;

unsigned int scaleFactor;
unsigned int i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExpArg, y, &scaleFactor, NULL);
if (i == (unsigned int)-1)
size_t i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExpArg, y, &scaleFactor, NULL);
if (i == (size_t)-1)
goto cellIsEmpty;

if (deltaExp >= UINT16_WIDTH) {
Expand Down

0 comments on commit a9c4868

Please sign in to comment.