C言語なら俺に聞け! Part 94
■ このスレッドは過去ログ倉庫に格納されています
0040デフォルトの名無しさん
NGNGFooStruct * initFoo(void)
{
static FooStruct * sFoo;
if (sFoo == NULL) {
sFoo = malloc(sizeof(FooStruct));
}
setSomeFoo(sFoo);
return sFoo;
}
当然、free()してない。
或いはこういうコードも。
FooStruct * allocFoo(unsigned cnt)
{
static FooStruct * sFoo;
if (sFoo) {
free(sFoo);
}
sFoo = malloc(sizeof(FooStruct) * cnt);
setSomeFoos(sFoo, cnt);
return sFoo;
}
やはり、最後はfree()してない。
■ このスレッドは過去ログ倉庫に格納されています