MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / finalizeVariant

Method finalizeVariant

src/library/fft_binary_lookup.cpp:268–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void FFTBinaryLookup::finalizeVariant()
269{
270 // serialize variants
271 size_t whole_variant_size_in_bytes = 0;
272
273 // store 1 byte for the variant kind
274 whole_variant_size_in_bytes += this->m_variants.size() * sizeof(int); // for the variant kind
275 whole_variant_size_in_bytes += this->m_variants.size() * sizeof(size_t); // for the variant size
276
277 // add every variant sizes
278 for(size_t i=0 ; i<this->m_variants.size() ; ++i)
279 {
280 const Variant & v = this->m_variants[i];
281
282 // compute the whole size of the signature
283 whole_variant_size_in_bytes += v.m_size;
284 }
285
286 this->m_header.signature_size = whole_variant_size_in_bytes;
287
288 if (this->m_signature != NULL)
289 {
290 delete[] this->m_signature;
291 this->m_signature = 0;
292 }
293
294 this->m_signature = new char[whole_variant_size_in_bytes];
295 char * current_address = this->m_signature;
296 for(size_t i=0 ; i<this->m_variants.size() ; ++i)
297 {
298 Variant v = this->m_variants[i];
299
300 // write the variant kind
301 memcpy(current_address, &v.m_kind, sizeof(int));
302 current_address += sizeof(v.m_kind);
303
304 // write the variant size
305 memcpy(current_address, &v.m_size, sizeof(v.m_size));
306 current_address += sizeof(v.m_size);
307
308 // write the variant itself
309 memcpy(current_address, v.m_data, v.m_size);
310 current_address += v.m_size;
311 }
312
313 // Update the cache entry name if there are variants...
314 if (whole_variant_size_in_bytes != 0)
315 {
316 char md5_sum[33];
317 md5sum(this->m_signature, (unsigned long)this->m_header.signature_size, md5_sum);
318 this->m_cache_entry_name = md5_sum;
319 }
320 else
321 {
322 this->m_cache_entry_name += ".db";
323 }
324}
325

Callers 1

foundMethod · 0.95

Calls 2

md5sumFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected