• <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 閱讀(184) 評論(0)  編輯 收藏 引用

            久久久无码精品亚洲日韩蜜臀浪潮 | 午夜精品久久久久久99热| 久久国产精品波多野结衣AV| 久久这里有精品视频| 无码专区久久综合久中文字幕| 日韩精品久久久肉伦网站| 久久精品中文字幕久久| 久久九九久精品国产免费直播| 狠狠色丁香久久婷婷综合| 久久亚洲高清观看| 久久久精品国产免大香伊| 欧美亚洲国产精品久久蜜芽| 久久精品视频一| 久久成人影院精品777| 伊人久久大香线焦AV综合影院| 99久久精品国产一区二区| 三上悠亚久久精品| 日产久久强奸免费的看| 久久久精品免费国产四虎| 亚洲国产精品无码久久| 狠狠色丁香久久婷婷综合_中 | 亚洲午夜久久久久久久久久| 精品乱码久久久久久夜夜嗨| 久久精品中文无码资源站| 久久午夜福利无码1000合集| 久久久精品一区二区三区| 久久国产欧美日韩精品| 日韩精品久久久久久久电影蜜臀 | 手机看片久久高清国产日韩| 91精品国产91久久久久久蜜臀 | 色综合久久最新中文字幕| 国产精品国色综合久久| 伊人久久综合成人网| 亚洲国产另类久久久精品| 午夜天堂av天堂久久久| 一本色道久久综合狠狠躁| 久久精品国产亚洲AV忘忧草18 | 久久99国产精品一区二区| 国产精品久久久久久一区二区三区| av色综合久久天堂av色综合在| 久久99精品国产麻豆宅宅|