Page MenuHome

check_for_dupid2.patch

check_for_dupid2.patch

commit 4cbaa6f89455f55d10bd9355185326d47b426929
Author: Lawrence D'Oliveiro <ldo@geek-central.gen.nz>
Date: Thu Feb 7 08:42:28 2013 +0000
check_for_dupid comments:
correct comment about in_use array
note name-truncation code will never be executed
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 9709e17..6dc9124 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1234,7 +1234,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
max_in_use = 64, /* something reasonable */
};
bool in_use[max_in_use];
- /* to speed up finding unused numbers within [1 .. max_in_use - 1] (in_use[0] not used) */
+ /* to speed up finding unused numbers within [0 .. max_in_use - 1] */
char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
@@ -1275,18 +1275,24 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
(BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len)
)
{
+ /* will get here at least once, otherwise is_dupid call above would have returned NULL */
if (nrtest < max_in_use)
in_use[nrtest] = true; /* mark as used */
if (nr <= nrtest)
nr = nrtest + 1; /* track largest unused */
}
}
+ /* At this point, nr will be at least 1. */
/* decide which value of nr to use */
for (a = 0; a < max_in_use; a++) {
if (a >= nr) break; /* stop when we've checked up to biggest */ /* redundant check */
if (!in_use[a]) { /* found an unused value */
nr = a;
+ /* can only be zero if all potential duplicate names had
+ nonzero numeric suffixes, which means name itself has
+ nonzero numeric suffix (else no name conflict and wouldn't
+ have got here), which means name[left_len] is not a null */
break;
}
}
@@ -1299,6 +1305,8 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
* shave off the end chars until we have a unique name.
* Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */
if (nr == 0 && name[left_len] == '\0') {
+ /* FIXME: this code will never be executed, because either nr will be
+ at least 1, or name will not end at left_len! */
int len = left_len - 1;
idtest = is_dupid(lb, id, name);

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7d/5a/0d5dce42ae2bd8d0c283381b0fcb

Event Timeline