• <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)  編輯 收藏 引用

            久久精品人人做人人爽电影| 国产成人精品久久| 久久久午夜精品福利内容| 久久笫一福利免费导航| 亚洲精品乱码久久久久久| 国产精品久久久久久影院| 一级女性全黄久久生活片免费 | 久久综合久久综合九色| 亚洲精品NV久久久久久久久久 | 久久精品成人免费观看97| 99久久国产综合精品女同图片| 东京热TOKYO综合久久精品| 久久人人爽人人爽人人片av麻烦| 久久精品无码一区二区三区| 思思久久99热免费精品6| 国产69精品久久久久99| 国产精品99久久久精品无码| 精品久久久久一区二区三区 | 久久久久久久精品妇女99| 四虎国产精品免费久久久| 久久精品中文闷骚内射| 久久一日本道色综合久久| 亚洲精品乱码久久久久久自慰| 99久久久久| 四虎影视久久久免费| 伊人久久综合热线大杳蕉下载| 色婷婷综合久久久久中文一区二区| 久久久久久A亚洲欧洲AV冫| 国产精品久久久久9999高清| 久久99久国产麻精品66| 欧美亚洲国产精品久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 77777亚洲午夜久久多喷| 精品蜜臀久久久久99网站| 久久久久久亚洲精品成人| 亚洲AV日韩精品久久久久久久| 久久综合亚洲鲁鲁五月天| 国产免费久久精品99re丫y| 99久久夜色精品国产网站| 国产成人久久精品一区二区三区| 久久久午夜精品福利内容|