Skip to content

Commit

Permalink
valueCellIndex() return type in size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 3, 2024
1 parent 69452e3 commit 9840c89
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 @@ -320,7 +320,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 @@ -333,7 +333,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 @@ -358,7 +358,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 @@ -586,7 +586,7 @@ static void GraphMeterMode_computeColors(Meter* this, const GraphDrawContext* co
assert(numDots > 0 && numDots <= (int)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);

unsigned int topCell = ((unsigned int)numDots - 1) / 8;
const uint8_t dotAlignment = 2;
Expand Down Expand Up @@ -887,9 +887,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 @@ -1022,8 +1022,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 9840c89

Please sign in to comment.