JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
<stdlib.h> (C) / <cstdlib> (C++)で宣言されマクロとして定義された以下を使用しています: malloc()、calloc()、realloc()、free()。
一部のコーディング規約では、これらのマクロは認められていません。
libcの実装でこれらを 関数として定義している場合、このワーニングの代わりにUse of <stdlib.h> Allocator/Deallocatorが検出されます。
| クラス名 | Use of <stdlib.h> Allocator/Deallocator Macro | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | stdlib.hで宣言されたAllocator Macro及びDeallocator Macroの使用 | |||||||||||||||||||||||||||||||||
| クラス分類 | スタイル (style) | |||||||||||||||||||||||||||||||||
| ニーモニック | BADMACRO.STDLIB_H_MEM | |||||||||||||||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Use of <stdlib.h> Allocator/Deallocator Macro" |
#include <cstdlib>
class Intpair {
public:
int a;
int b;
Intpair(int aval, int bval): a(aval),b(bval){}
int sum(){return a+b;}
};
int baduse(){
int s;
Intpair *i = (Intpair*)malloc(sizeof(Intpair)); // Warning issued here:
// - 'Use of <stdlib.h> Allocator/Deallocator Macro' if malloc() implemented as a macro
// - 'Use of <stdlib.h> Allocator/Deallocator' if malloc() implemented as a function
if (i==NULL) {return 0;}
i->a = 5;
i->b = 7;
s = i->sum();
free(i); // Warning issued here:
// - 'Use of <stdlib.h> Allocator/Deallocator Macro' if free() implemented as a macro
// - 'Use of <stdlib.h> Allocator/Deallocator' if free() implemented as a function
return s;
}
int gooduse(){ // OK: uses constructor and destructor instead of malloc/free.
Intpair *i = new Intpair(5,7);
int s = i->sum();
delete i;
return s;
}
このクラスは一般テンプレート設定ファイルで BAD_MACRO_* ルールセットによって実装されています。
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.