提交 fcc3cc8e 编写于 作者: A AlexDuan

max index over array

上级 37b58873
......@@ -162,7 +162,8 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
#if defined(USE_ARRAYLIST)
int32_t idx = histoBinarySearch((*pHisto)->elems, (*pHisto)->numOfEntries, val);
assert(idx >= 0 && idx <= (*pHisto)->maxEntries && (*pHisto)->elems != NULL);
if(idx >= (*pHisto)->maxEntries) idx = (*pHisto)->maxEntries - 1;
assert(idx >= 0 && idx < (*pHisto)->maxEntries && (*pHisto)->elems != NULL);
if ((*pHisto)->elems[idx].val == val && idx >= 0) {
(*pHisto)->elems[idx].num += 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册