diff options
author | Ton Roosendaal <ton@blender.org> | 2006-11-26 15:23:21 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-11-26 15:23:21 +0300 |
commit | ced3b0fd6f4740a5fa9eba3f78b490a4a5467168 (patch) | |
tree | babb99ffbc344b3b1665a389224bf70db0f13724 /source/blender/makesdna/intern/makesdna.c | |
parent | 6ede6352edf5c83e963e827d0de6ce92f48d9442 (diff) |
SculptMode fix:
DNA definition of Sculpt structs in Scene were not properly aligned,
causing memory errors on quit ("Memoryblock reconstruct: end corrupt").
More testing reveiled padding errors in two other DNA_ includes, for
sound and gamelogic. Both potentially crashers... and caused by
commenting out struct members with a C++ comment, that seems to not
work...
I've revived the DNA padding test method, which saves out a simple C
file you can compile to see where padding issues are. This now works
as follows:
- change line 991 in makesdna.c to become (1) (true).
- recompile makesdna.c
- you now have a padding.c in the same dir as makesdna.c
- compile it, command line: "gcc -o padding padding.c"
- now run it (./padding), and it will print out errors, if there are.
For me, the DNA files are now 100% padding free. Might be interesting to
check it in 64 bits though!
Diffstat (limited to 'source/blender/makesdna/intern/makesdna.c')
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 79e839a172f..1061581d7c5 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -141,7 +141,7 @@ int nr_structs=0; char **names, *namedata; /* at adress names[a] is string a */ char **types, *typedata; /* at adress types[a] is string a */ short *typelens; /* at typelens[a] is de length of type a */ -short *alphalens; /* contains sizes as they are calculated on the alpha */ +short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits) */ short **structs, *structdata; /* at sp= structs[a] is the first adress of a struct definition sp[0] is type number sp[1] is amount of elements @@ -870,7 +870,7 @@ int make_structDNA(char *baseDirectory, FILE *file) add_type("short", 2); /* 2 */ add_type("ushort", 2); /* 3 */ add_type("int", 4); /* 4 */ - add_type("long", 4); /* 5 */ + add_type("long", 4); /* 5 */ /* should it be 8 on 64 bits? */ add_type("ulong", 4); /* 6 */ add_type("float", 4); /* 7 */ add_type("double", 8); /* 8 */ @@ -988,7 +988,6 @@ int make_structDNA(char *baseDirectory, FILE *file) dna_write(file, structs[0], len); /* a simple dna padding test */ - if (0) { FILE *fp; int a; @@ -999,16 +998,18 @@ int make_structDNA(char *baseDirectory, FILE *file) // add all include files defined in the global array for (i = 0; strlen(includefiles[i]); i++) { - fprintf(fp, "#include \"%s\"\n", includefiles[i]); + fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]); } fprintf(fp, "main(){\n"); sp = typelens; sp += firststruct; for(a=firststruct; a<nr_types; a++, sp++) { - fprintf(fp, "\tprintf(\" "); - fprintf(fp, "%%d %s %d ", types[a], *sp); - fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp); + if(*sp) { + fprintf(fp, "\tif(sizeof(struct %s) - %d) printf(\"ALIGN ERROR:", types[a], *sp); + fprintf(fp, "%%d %s %d ", types[a], *sp); + fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp); + } } fprintf(fp, "}\n"); fclose(fp); |