PB組み込みのテンプレートライブラリ
先日、ある理由があってWindows CE (Platform Builder) 5.0のドライバーのソースコードツリーをチェックしていたところ、以下のような不思議なテンプレートコードがあるのに気が付きました。
ce::fixed_block_allocator<> m_fba;
size_t m_cbEntry;
いつものようにCOMMON以下の各INCフォルダをサーチしてみると、COMMON\OAK\INC下にこの定義を含む
block_allocator.hxx
というヘッダーファイルがあります。Platform Builderで.hxxという拡張子は珍しいので、同様の拡張子で似たようなものがないかと調べると...
allocator.hxx *
auto_xxx.hxx *
block_allocator.hxx
combined_container.hxx *
handle_map.hxx
hash.hxx
hash_map.hxx *
hash_set.hxx
list.hxx *
notifext.hxx *
psl_marchaler.hxx
safe_array.hxx *
singleton.hxx
string.hxx *
sync.hxx *
vector.hxx *
のように多岐にわたります。一方、COMMON\SDK\INC下にも
creg.hxx *
svsutil.hxx *
の2つのファイルが見つかりました。( *印の付いているものは CE.NET 4.2から存在していました。)
block_allocator.hxxのコメント部には以下のような記述がありました。
/// Creating a block allocator that has 50 initial blocks at compile-time...
ce::fixed_block_allocator<50> al;
/// ...and at run-time
size_t cBlocks = 50;
ce::fixed_block_allocator<> al2(cBlocks);
/// Allocating a single item from a fixed block
MyStruct* pStruct = (MyStruct*)al.allocate(sizeof(MyStruct));
/// Freeing a single item from a fixed block
al.deallocate(pStruct, sizeof(MyStruct));
その後、たまたま"svsutil"でサーチをかけてみたところ、以下のBlogの記事が見つかりました。
Windows CE Networking Team WebLog
"What the heck is svsutil.hxx?"
これは要するに、PBで一般に使ってもよいテンプレートライブラリだが、ドキュメントもなければサポートもないので注意して使ってね!と言っているようですね。