• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ++wythern++

            X presents Y for a better Z

            Usage of zero element array

            Source: http://stackoverflow.com/questions/4255193/declaring-zero-size-vector

            This is called a flexible array member, and in C99 is written as char bar[];, and in C89 was written as char bar[1];, and which some compilers would let you write as char bar[0];. Basically, you only use pointers to the structure, and allocate them all with an amount of extra space at the end:

            const size_t i = sizeof("Hello, world!");
            struct foo *p = malloc(offsetof(struct foo, bar) + i);
            memcpy(p->bar, "Hello, world!", i);
            // initialize other members of p
            printf("%s\n", p->bar);

            That way, p->bar stores a string whose size isn't limited by an array declaration, but which is still all done in the same allocation as the rest of the struct (rather than needing the member to be a char * and need two mallocs and two frees to set it up).

            好處:連續(虛擬)內存空間以及僅需一次的free操作。

            posted on 2011-05-04 13:37 wythern 閱讀(182) 評論(0)  編輯 收藏 引用

            伊人久久五月天| 欧美麻豆久久久久久中文| 精品久久久久久久久久中文字幕 | 国产成人精品久久| 日本强好片久久久久久AAA| 国内精品久久久久久99| 一级做a爰片久久毛片人呢| 久久免费视频6| 午夜久久久久久禁播电影| 日本福利片国产午夜久久| 久久久久久青草大香综合精品| 久久亚洲AV无码西西人体| 亚洲人成网亚洲欧洲无码久久| 久久久久中文字幕| 久久精品人妻中文系列| 久久福利青草精品资源站免费| 国产成人综合久久久久久| 日韩精品久久久肉伦网站| 久久精品18| 久久精品无码专区免费青青| 日本精品久久久久影院日本| 国产成人精品久久一区二区三区| 亚洲国产成人久久综合一区77| 久久精品国产一区| 精品伊人久久大线蕉色首页| 国产亚洲精午夜久久久久久| 久久99亚洲网美利坚合众国| 香蕉久久夜色精品国产尤物| 品成人欧美大片久久国产欧美| 狠狠色综合网站久久久久久久高清| 99久久精品免费看国产| 久久婷婷国产综合精品 | 国内精品久久久久久野外| 99久久精品免费看国产一区二区三区| 2021少妇久久久久久久久久| 久久人人爽人人爽人人片AV不| 欧美久久亚洲精品| 久久国产成人午夜AV影院| 久久久青草久久久青草| 久久国产精品-久久精品| 久久99精品综合国产首页|