Sunday, October 24, 2010

Stack and Heap Snippet

*Stack allocation
Image myImage;
myImage.SetAllPixels(ClearColor);

*Heap allocation
Image *imagePtr;
imagePtr = new Image();
imagePtr->SetAllPixels(ClearColor);

...

delete imagePtr;

Stack allocation: Constructor and destructor called automatically when the function is entered and exited.
Heap allocation: Constructor and destructor must be called explicitly.

Wednesday, October 20, 2010

How to know if your PC is 64 bit?

Description:
There is a processor flag called lm "long mode" means this processor is a 64-bit capable.
Procedure:
cat proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm ida

note: Also another flag called vmx that tells this processor supports virtualization Technology for Intel processors.