use 'greater/less then or equal to' operators rather then adding 1.

This commit is contained in:
Campbell Barton 2013-08-11 05:40:35 +00:00
parent a62163ada3
commit 98c574e41a
18 changed files with 24 additions and 22 deletions

@ -975,7 +975,7 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...)
/* Allocate the new memory for the index entry */
if (frame_num + 1 > movie->index_entries) {
if (frame_num >= movie->index_entries) {
const size_t entry_size = (movie->header->Streams + 1) * sizeof(AviIndexEntry);
movie->entries = (AviIndexEntry *)MEM_recallocN(movie->entries, (frame_num + 1) * entry_size);
movie->index_entries = frame_num + 1;

@ -152,7 +152,7 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc)
}
}
if (gc->cur_tex + 1 > 0)
if (gc->cur_tex > -1)
glDeleteTextures(gc->cur_tex + 1, gc->textures);
MEM_freeN((void *)gc->textures);
MEM_freeN(gc);

@ -602,7 +602,7 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl
float cur_u = 0.0f, cur_w = 0.0f, next_u = 0.0f, next_w = 0.0f, fac; /* Quite warnings */
int i;
for (i = 0; i < point->tot_uw + 1; i++) {
for (i = 0; i <= point->tot_uw; i++) {
if (i == 0) {
cur_u = 0.0f;

@ -349,7 +349,7 @@ static void add_in_range(KDTreeNearest **ptn, int found, int *totfoundstack, int
{
KDTreeNearest *to;
if (found + 1 > *totfoundstack) {
if (found >= *totfoundstack) {
KDTreeNearest *temp = MEM_callocN((*totfoundstack + 50) * sizeof(KDTreeNode), "psys_treefoundstack");
memcpy(temp, *ptn, *totfoundstack * sizeof(KDTreeNearest));
if (*ptn)

@ -593,7 +593,7 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
}
for (i = 1; i < numcuts + 2; i++) {
for (j = 1; j < numcuts + 1; j++) {
for (j = 1; j <= numcuts; j++) {
a = i * s + j;
b = (i - 1) * s + j;
e = connect_smallest_face(bm, lines[a], lines[b], &f_new);
@ -710,7 +710,7 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
* s s
* </pre>
*/
for (i = 1; i < numcuts + 1; i++) {
for (i = 1; i <= numcuts; i++) {
for (j = 0; j < i; j++) {
e = connect_smallest_face(bm, lines[i][j], lines[i + 1][j + 1], &f_new);

@ -561,7 +561,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid lines here */
for (i = 1; i < (HISTOGRAM_TOT_GRID_LINES + 1); i++) {
for (i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
/* so we can tell the 1.0 color point */

@ -165,7 +165,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
int j;
for (j = 0; j < point->tot_uw + 1; j++) {
for (j = 0; j <= point->tot_uw; j++) {
float feather_point[2];
int sel = FALSE;

@ -197,7 +197,7 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
int j;
MaskSplinePoint *cur_point = &spline->points[i];
for (j = 0; j < cur_point->tot_uw + 1; j++) {
for (j = 0; j <= cur_point->tot_uw; j++) {
float cur_len, vec[2];
vec[0] = (*fp)[0] * scalex;

@ -562,6 +562,7 @@ static void time_main_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AR
ED_region_tag_redraw(ar);
break;
}
break;
}
}

@ -1485,7 +1485,7 @@ static void draw_dof_ellipse(float ax, float az)
z = staticSine[i];
px = 0.0f;
for (j = 1; j < n - i + 1; j++) {
for (j = 1; j <= (n - i); j++) {
x = staticSine[j];
if (j == n - i) {

@ -6780,7 +6780,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
cpack(0xffffff);
set_inverted_drawing(1);
for (i = 0; i < (selend - selstart + 1); i++) {
for (i = 0; i <= (selend - selstart); i++) {
SelBox *sb = &(cu->selboxes[i]);
if (i < (selend - selstart)) {

@ -826,6 +826,7 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
if (rv3d->persp == RV3D_CAMOB) {
ED_region_tag_redraw(ar);
}
break;
}
}
break;

@ -478,7 +478,7 @@ FitCurveWrapper::~FitCurveWrapper()
void FitCurveWrapper::DrawBezierCurve(int n, Vector2 *curve)
{
for (int i = 0; i < n + 1; ++i)
for (int i = 0; i <= n; ++i)
_vertices.push_back(curve[i]);
}

@ -414,10 +414,10 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices)
cerr << "Stephane dit \"Toto\"" << endl;
//traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu1; j < i + 1; j++)
for (j = i - timeSinceSingu1; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j]->point2d());
avP = Vec2r( 1.0 / float(timeSinceSingu1 + 1) * avP);
for (j = i - timeSinceSingu1; j < i + 1; j++)
for (j = i - timeSinceSingu1; j <= i; j++)
_vertices[2 * j]->setPoint2d(avP);
//_vertex[2 * j] = _vertex[2 * i];
singu1 = false;
@ -435,10 +435,10 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices)
cerr << "Stephane dit \"Toto\"" << endl;
//traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu2; j < i + 1; j++)
for (j = i - timeSinceSingu2; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j + 1]->point2d());
avP = Vec2r(1.0 / float(timeSinceSingu2 + 1) * avP);
for (j = i - timeSinceSingu2; j < i + 1; j++)
for (j = i - timeSinceSingu2; j <= i; j++)
_vertices[2 * j + 1]->setPoint2d(avP);
//_vertex[2 * j + 1] = _vertex[2 * i + 1];
singu2 = false;

@ -74,7 +74,7 @@ SteerableViewMap::SteerableViewMap(const SteerableViewMap& iBrother)
_directions = iBrother._directions;
_mapping = iBrother._mapping;
_imagesPyramids = new ImagePyramid *[_nbOrientations + 1]; // one more map to store the complete visible VM
for (i = 0; i < _nbOrientations + 1; ++i)
for (i = 0; i <= _nbOrientations; ++i)
_imagesPyramids[i] = new GaussianPyramid(*(dynamic_cast<GaussianPyramid*>(iBrother._imagesPyramids[i])));
}

@ -982,7 +982,7 @@ int load(istream& in, ViewMap *vm, ProgressBar *pb)
if (fe_s) {
bool b;
READ(b);
for (READ(fe_rle1), fe_rle2 = 0; fe_rle1 < fe_s + 1; fe_rle2 = fe_rle1, READ(fe_rle1)) {
for (READ(fe_rle1), fe_rle2 = 0; fe_rle1 <= fe_s; fe_rle2 = fe_rle1, READ(fe_rle1)) {
if (b) {
for (unsigned int i = fe_rle2; i < fe_rle1; i++) {
FEdgeSmooth *fes = new FEdgeSmooth;
@ -1007,7 +1007,7 @@ int load(istream& in, ViewMap *vm, ProgressBar *pb)
if (vv_s) {
Nature::VertexNature nature;
READ(nature);
for (READ(vv_rle1), vv_rle2 = 0; vv_rle1 < vv_s + 1; vv_rle2 = vv_rle1, READ(vv_rle1)) {
for (READ(vv_rle1), vv_rle2 = 0; vv_rle1 <= vv_s; vv_rle2 = vv_rle1, READ(vv_rle1)) {
if (nature & Nature::T_VERTEX) {
for (unsigned int i = vv_rle2; i < vv_rle1; i++) {
TVertex *tv = new TVertex();

@ -318,8 +318,8 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
/* create vertices */
#pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES)
for (y = 0; y < res_y + 1; y++) {
for (x = 0; x < res_x + 1; x++) {
for (y = 0; y <= res_y; y++) {
for (x = 0; x <= res_x; x++) {
const int i = y * (res_x + 1) + x;
float *co = mverts[i].co;
co[0] = ox + (x * sx);

@ -567,7 +567,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
node->child[b].node = child;
/* keep track of maximum depth for stack */
if (depth + 1 > tree->maxdepth)
if (depth >= tree->maxdepth)
tree->maxdepth = depth + 1;
if (tree->dothreadedbuild)