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

            狠狠色丁香久久综合五月| 一本大道久久香蕉成人网| 久久亚洲私人国产精品vA| 999久久久免费精品国产| 国产精品99久久久久久www| 中文字幕精品久久| 777米奇久久最新地址| 久久精品国产欧美日韩| 久久99精品久久久久久动态图| 国产成人久久久精品二区三区| 狠狠色综合网站久久久久久久高清| 久久99精品久久久久久久久久| 久久久噜噜噜久久| 精品久久一区二区| 久久婷婷五月综合国产尤物app| 97久久精品人人澡人人爽| 中文字幕久久波多野结衣av| 精品久久国产一区二区三区香蕉 | 精品国产乱码久久久久久郑州公司 | 国产精品99久久久久久www| 少妇久久久久久久久久| 久久婷婷人人澡人人| 69久久夜色精品国产69 | 99久久www免费人成精品| 亚洲va久久久噜噜噜久久| 狠狠色丁香久久婷婷综合图片| 999久久久国产精品| 久久精品国产影库免费看| 69SEX久久精品国产麻豆| 无码精品久久久天天影视| 99久久香蕉国产线看观香| 久久人人爽人人爽人人片AV高清| 久久久久综合国产欧美一区二区| 国内精品久久久久久麻豆| 精品久久久久中文字幕一区| 一级做a爱片久久毛片| 国产精品美女久久久免费 | 久久久一本精品99久久精品88| 久久婷婷五月综合成人D啪| 久久www免费人成看片| 国内精品久久久久久久久电影网|