• <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).

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

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

            国产欧美久久久精品| 久久精品久久久久观看99水蜜桃| 日韩AV无码久久一区二区| 久久综合给久久狠狠97色| 99久久精品国产一区二区三区| 久久婷婷五月综合色99啪ak| 亚洲国产一成人久久精品| 热99re久久国超精品首页| 亚洲AV无码1区2区久久| 国产精品免费看久久久香蕉| 久久无码中文字幕东京热| 久久播电影网| 久久精品国产免费一区| 亚洲狠狠婷婷综合久久蜜芽| 久久精品亚洲精品国产欧美| 久久被窝电影亚洲爽爽爽| 久久精品人人做人人爽97| 2021久久精品免费观看| 久久影视综合亚洲| 国产日韩久久免费影院| 久久香蕉国产线看观看乱码| 久久丫精品国产亚洲av不卡 | 久久久无码一区二区三区| 久久久久国产精品麻豆AR影院| 国产一级持黄大片99久久| 久久久无码精品亚洲日韩按摩| 中文字幕热久久久久久久| 欧美精品九九99久久在观看| 久久人人爽人人爽AV片| 国产高清国内精品福利99久久| 中文字幕一区二区三区久久网站| 精品九九久久国内精品| 欧美亚洲另类久久综合| 精品久久久久久久久中文字幕| 精品国产VA久久久久久久冰 | 99久久免费只有精品国产| 亚洲一区二区三区日本久久九| 久久久久国产一级毛片高清版| 婷婷综合久久狠狠色99h| 精品国产综合区久久久久久| 久久丝袜精品中文字幕|