Skip to main content

Test Post

Write your post here.

Learning Piano

Project overview and current status here...

Browser usage evolution (in %) 00101020203030404050506060707080802002200320042005200620070241.18397435897435504.11538461538464200416.6346.5044871794872456.3051819974897200525451.825432.11206741975974200631557.1455128205129414.83127129280973200785.876.88397435897436257.0200284.6182.20448717948716260.45615922539200384.7287.525260.1681459566075200474.5392.84551282051285289.54549937242246200566498.1660256410256314.0266272189349200658.6603.4865384615385335.33960910883985200714.2100.05448717948718463.2175004482697200215.4205.375459.7613412228797200315.3310.6955128205128460.049354491662220048.9416.0160256410257478.482203693742220059521.3365384615385478.19419042495963200610.4626.6570512820514474.16200466200472007Browser usage evolution (in %)FirefoxChromeIEOthers

😢

#include 
#include 

int nonHeapInt;

struct HeapObject
{
    int x;  // 因為如果找 x 的 pointer,實際上和找 HeapObject 的開頭 pointer 相同,
            // 所以我們必需加一個y,讓我們指定 pointer 時不會指到 HeapObject 的開頭。
    int y;
};

int main()
{
    struct HeapObject * heapObject = malloc(sizeof(struct HeapObject));

    nonHeapInt = 10;
    heapObject->y = 20;

    printf("Start nonHeapInt:%d\n", nonHeapInt);
    printf("Start heapObject->y:%d\n", heapObject->y);

    // free(&nonHeapInt); // GCC 會警告,執行 glibc 會丟 invalid pointer exception
    // free(&(heapObject->y)); // 雖然不會景告,但 glibc 還是會丟 invalid pointer exception

    printf("End nonHeapInt:%d\n", nonHeapInt);
    printf("End heapObject->y:%d\n", heapObject->y);

}