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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2007-04-24 18:52:35 +0400
committerTon Roosendaal <ton@blender.org>2007-04-24 18:52:35 +0400
commit46545ac575e500d46aae3fabb05f6d46a7fb1797 (patch)
tree1fc020f78bbe1300e243068fd8665f26097c6661 /source
parent1ad4f024c8d73ead1867378d33bba47689473087 (diff)
64 bits safety:
- makesdna now checks for struct-in-struct alignment (default 8 byte align) - fixed two occurances of such struct-in-struct align errors
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_ID.h6
-rw-r--r--source/blender/makesdna/DNA_scene_types.h6
-rw-r--r--source/blender/makesdna/intern/makesdna.c12
3 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index ce03bdc5e84..14e39faf2c6 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -57,15 +57,15 @@ typedef struct IDProperty {
char name[32];
char type, subtype;
short flag;
- IDPropertyData data;
+ int saved; /*saved is used to indicate if this struct has been saved yet.
+ seemed like a good idea as a pad var was needed anyway :)*/
+ IDPropertyData data; /* note, alignment for 64 bits */
int len; /* array length, also (this is important!) string length + 1.
the idea is to be able to reuse array realloc functions on strings.*/
/*totallen is total length of allocated array/string, including a buffer.
Note that the buffering is mild; the code comes from python's list implementation.*/
int totallen; /*strings and arrays are both buffered, though the buffer isn't
saved. at least it won't be when I write that code. :)*/
- int saved; /*saved is used to indicate if this struct has been saved yet.
- seemed like a good idea as a pad var was needed anyway :)*/
} IDProperty;
#define MAX_IDPROP_NAME 32
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 9c3d82ab2c2..c81720b5555 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -335,11 +335,11 @@ typedef struct ToolSettings {
short pad2;
+ /* Image Paint (8 byte aligned please!) */
+ struct ImagePaintSettings imapaint;
+
/* Select Group Threshold */
float select_thresh;
-
- /* Image Paint */
- struct ImagePaintSettings imapaint;
/* IPO-Editor */
float clean_thresh;
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 1061581d7c5..4d437861751 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -195,7 +195,7 @@ int arraysize(char *astr, int len);
/**
* Determine how many bytes are needed for each struct.
*/
-int calculate_structlens(void);
+static int calculate_structlens(int);
/**
* Construct the DNA.c file
@@ -649,7 +649,7 @@ int arraysize(char *astr, int len)
return mul;
}
-int calculate_structlens(void)
+static int calculate_structlens(int firststruct)
{
int a, b, len, alphalen, unknown= nr_structs, lastunknown, structtype, type, mul, namelen;
short *sp, *structpoin;
@@ -712,6 +712,12 @@ int calculate_structlens(void)
mul= 1;
if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
+ /* struct alignment */
+ if(type >= firststruct) {
+ if(sizeof(void *)==8 && (len % 8) )
+ printf("Align struct error: %s %s\n", types[structtype],cp);
+ }
+
/* 2-4 aligned/ */
if(typelens[type]>3 && (len % 4) ) {
printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len%4);
@@ -893,7 +899,7 @@ int make_structDNA(char *baseDirectory, FILE *file)
}
if (debugSDNA) printf("\tFinished scanning %d headers.\n", i);
- if (calculate_structlens()) {
+ if (calculate_structlens(firststruct)) {
// error
return(1);
}