- if (true) {
- std::stringbuf data;
-
- uint32_t normal((allocation.limit_ + pagesize - 1) / pagesize);
-
- Blob blob;
- blob.magic = Swap(CSMAGIC_CODEDIRECTORY);
- blob.length = Swap(uint32_t(sizeof(blob) + sizeof(CodeDirectory) + strlen(name) + 1 + SHA_DIGEST_LENGTH * (allocation.special_ + normal)));
- put(data, &blob, sizeof(blob));
-
- CodeDirectory directory;
- directory.version = Swap(uint32_t(0x00020001));
- directory.flags = Swap(uint32_t(0));
- directory.hashOffset = Swap(uint32_t(sizeof(blob) + sizeof(CodeDirectory) + strlen(name) + 1 + SHA_DIGEST_LENGTH * allocation.special_));
- directory.identOffset = Swap(uint32_t(sizeof(blob) + sizeof(CodeDirectory)));
- directory.nSpecialSlots = Swap(allocation.special_);
- directory.codeLimit = Swap(allocation.limit_);
- directory.nCodeSlots = Swap(normal);
- directory.hashSize = SHA_DIGEST_LENGTH;
- directory.hashType = CS_HASHTYPE_SHA1;
- directory.spare1 = 0x00;
- directory.pageSize = pageshift;
- directory.spare2 = Swap(uint32_t(0));
- put(data, &directory, sizeof(directory));
-
- put(data, name, strlen(name) + 1);
-
- uint8_t storage[allocation.special_ + normal][SHA_DIGEST_LENGTH];
- uint8_t (*hashes)[SHA_DIGEST_LENGTH] = storage + allocation.special_;
-
- memset(storage, 0, sizeof(*storage) * allocation.special_);
-
- _foreach (blob, blobs) {
- auto local(reinterpret_cast<const Blob *>(&blob.second[0]));
- sha1((uint8_t *) (hashes - blob.first), local, Swap(local->length));
- }