[cgma-dev] cgm-cubit on 32 bit machine

Jason Kraftcheck kraftche at cae.wisc.edu
Fri Jul 1 11:52:04 CDT 2011


On 07/01/2011 11:44 AM, Iulian Grindeanu wrote:
> 

> 
> Thanks Jason,
> So when I add at the end of CubitFile.hpp
> 
> Index: CubitFile.hpp
> ===================================================================
> --- CubitFile.hpp       (revision 5042)
> +++ CubitFile.hpp       (working copy)
> @@ -291,6 +291,7 @@
>          UnsignedInt32 mintNumModels;
>          SModelData* mpaModelData;
>      } mModelBuff;
> +    char buff[12];
>  };
> 
>  } // namespace NCubitFile
> 
> it compiles and runs "fine". If I do only char[4], it crashes early, and when I do
> char[8], it crashes more spectacularly, with a stack corruption.
> 

OK.  If you want to determine the exact size, you try something like this:

const char some_byte = 0xEE;
char some_mem[4096];
memset( some_mem, some_byte, sizeof(some_mem) );
CCubitFile* ptr = new (some_mem) CCubitFile;
size_t last_changed = 0;
for (size_t i = 0; i < sizeof(some_mem); ++i)
  if (some_mem[i] != some_byte)
    last_changed = i;
printf("CCubitFile constructor touched %lu bytes\n", (unsigned
long)last_changed+1);

But knowing the exact size probably isn't that important.


- jason


More information about the cgma-dev mailing list