Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-27 07:57:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-27 07:57:59 +0400
commitf3b7a49d5bac0179aeaaf5584fd0051ce5de1cdc (patch)
treef5c8e1f44cac41c0661e69778ac6f71e79ad89ac /source/blender/editors/curve/editcurve.c
parent2085a42e52f5b0d18a4516af15132d112b11a8c1 (diff)
fix for old bug, select more in a nurbs surface would crash (under allocing).
Diffstat (limited to 'source/blender/editors/curve/editcurve.c')
-rw-r--r--source/blender/editors/curve/editcurve.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index ae65cc9dbbe..3327d4a07e9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -47,6 +47,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_bitmap.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "BLI_rand.h"
@@ -5143,7 +5144,6 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
BPoint *bp, *tempbp;
int a;
short sel = 0;
- short *selbpoints;
/* note that NURBS surface is a special case because we mimic */
/* the behavior of "select more" of mesh tools. */
@@ -5151,11 +5151,12 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
/* may not be optimal always (example: end of NURBS sphere) */
if (obedit->type == OB_SURF) {
for (nu = editnurb->first; nu; nu = nu->next) {
+ BLI_bitmap selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
- selbpoints = MEM_callocN(sizeof(short) * a - nu->pntsu, "selectlist");
+ selbpoints = BLI_BITMAP_NEW(a, "selectlist");
while (a > 0) {
- if ((selbpoints[a] != 1) && (bp->hide == 0) && (bp->f1 & SELECT)) {
+ if ((!BLI_BITMAP_GET(selbpoints, a)) && (bp->hide == 0) && (bp->f1 & SELECT)) {
/* upper control point */
if (a % nu->pntsu != 0) {
tempbp = bp - 1;
@@ -5168,7 +5169,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
tempbp = bp + nu->pntsu;
if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE);
/* make sure selected bpoint is discarded */
- if (sel == 1) selbpoints[a - nu->pntsu] = 1;
+ if (sel == 1) BLI_BITMAP_SET(selbpoints, a - nu->pntsu);
}
/* right control point */
@@ -5233,13 +5234,13 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
BezTriple *bezt;
int a;
short sel = 0, lastsel = false;
- short *selbpoints;
if (obedit->type == OB_SURF) {
for (nu = editnurb->first; nu; nu = nu->next) {
+ BLI_bitmap selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
- selbpoints = MEM_callocN(sizeof(short) * a, "selectlist");
+ selbpoints = BLI_BITMAP_NEW(a, "selectlist");
while (a--) {
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
sel = 0;
@@ -5251,7 +5252,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
bp--;
- if ((selbpoints[a + 1] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_GET(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
bp++;
}
@@ -5269,7 +5270,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
bp -= nu->pntsu;
- if ((selbpoints[a + nu->pntsu] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_GET(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
bp += nu->pntsu;
}
@@ -5284,7 +5285,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
if (sel != 4) {
select_bpoint(bp, DESELECT, 1, VISIBLE);
- selbpoints[a] = 1;
+ BLI_BITMAP_SET(selbpoints, a);
}
}
else {