Skip to content
Tcl Source Code Artifact [43326406b2]
Login

Artifact [43326406b2]

Artifact 43326406b25c2b0d5c843529c4cd4aa90aed85bb:

Ticket change [43326406b2] - Ticket [3129448fffffffff|3129448fff] <i>possible over-allocation on 64-bit platforms</i> status still Closed with 4 other changes by nijtmans on 2010-12-06 23:12:12.
D 2010-12-06T23:12:12
J icomment Here\sis\sa\ssmall\stest\sprogram\s(try\sit\son\sany\sUNIX\smachine)\swhich\sshows\sthe\ndirrerence\sbetween\ssubstracting\stwo\ssizes\sor\sdetermining\sthe\soffset.\n\nThis\sprogram\sprints:\n\s\s\s\s12\s8\n\nHere\sI\sused\sa\slong\slong\sas\sdata\stype\sin\sstead\sof\san\sint.\sIt\swill\soccur\non\sany\smachine\swhere\ssizeof(int)\s=\s8.\n\n=====================================================\n#include\s<stdio.h>\n#define\sTclOffset(type,\sfield)\s\\\n((int)\s((char\s*)\s&((type\s*)\s0)->field))\ntypedef\sstruct\s{\nlong\slong\sdummy;\nchar\sbuf[4];\n}\smytype;\nvoid\smain()\s{\nmytype\sx;\nint\sanswer1\s=\ssizeof(x)\s-\ssizeof(x.buf);\nint\sanswer2\s=\s(unsigned)TclOffset(mytype,\sbuf);\nprintf("%d\s%d\\n",\sanswer1,\sanswer2);\n}\n\n
J login nijtmans
J mimetype text/plain
J username nijtmans
K 3129448fffffffffffffffffffffffffffffffff
U nijtmans
Z d5556284856d1eca1224c168d70adc18