bool MCGImageCreateCGDataProvider(MCGImageRef p_src, const MCGIntegerRectangle &p_src_rect, CGDataProviderRef &r_data_provider) { MCAssert(p_src_rect.origin.x >= 0 && p_src_rect.origin.y >= 0); MCAssert(p_src_rect.origin.x + p_src_rect.size.width <= (uint32_t)MCGImageGetWidth(p_src)); MCAssert(p_src_rect.origin.y + p_src_rect.size.height <= (uint32_t)MCGImageGetHeight(p_src)); bool t_success = true; MCGRaster t_raster; if (t_success) t_success = MCGImageGetRaster(p_src, t_raster); CGDataProviderRef t_data_provider; t_data_provider = nil; if (t_success) { const void *t_src_ptr; t_src_ptr = MCGRasterGetPixelPtr(t_raster, p_src_rect.origin.x, p_src_rect.origin.y); t_data_provider = CGDataProviderCreateWithData(p_src, t_src_ptr, p_src_rect.size.height * t_raster.stride, MCGImageDataProviderReleaseDataCallback); t_success = t_data_provider != nil; } if (t_success) { MCGImageRetain(p_src); r_data_provider = t_data_provider; } return t_success; }
Handle_ptr LetCommand::execute( Context &ctx, Environment *env, Handle_ptr expr) { MCAssertValidInstance(); MCAssert( 0 != expr && !eq( expr, ctx.NIL), "illegal expression"); if (!eq( expr->cdr(), ctx.NIL) && !eq( expr->cdr()->cdr(), ctx.NIL)) { // create new binding environment Environment *newEnv = env->makeChildEnvironment(); Handle_ptr bindList = expr->cdr()->car(); #if defined( DEBUG) && DEBUG > 2 std::cerr << "let bindings == "; printList( bindList, std::cerr); std::cerr << std::endl; #endif for ( ; !eq( bindList, ctx.NIL); bindList = bindList->cdr()) { Handle_ptr bindings = bindList->car(); #if defined( DEBUG) && DEBUG > 3 std::cerr << " evaluate binding "; printList( bindings, std::cerr); std::cerr << std::endl; #endif std::string key = bindings->car()->stringValue(); Handle_ptr value = ctx.eval->eval( bindings->cdr()->car()); newEnv->put( key, value); } // evaluate expressions in new environment ctx.eval->pushEnvironment( newEnv); Handle_ptr pos, evaluated = 0; #if defined( DEBUG) && DEBUG > 2 std::cerr << "let expressions == "; printList( expr->cdr()->cdr(), std::cerr); std::cerr << std::endl; #endif for (pos=expr->cdr()->cdr(); !eq( pos, ctx.NIL); pos=pos->cdr()) evaluated = ctx.eval->eval( pos->car()); ctx.eval->popEnvironment(); MCAssert( 0 != evaluated, "let failed to evaluate body"); return evaluated; } else { throw ArgumentCountException( -2, __FILE__, __LINE__); } MCAssertNotReached( 0); return 0; }
hash_t MCValueHash(MCValueRef p_value) { __MCValue *self = (__MCValue *)p_value; switch(__MCValueGetTypeCode(self)) { case kMCValueTypeCodeNull: return (hash_t)0xdeadbeef; case kMCValueTypeCodeBoolean: return p_value == kMCTrue ? 0xfeedbeef : 0xdeadfeed; case kMCValueTypeCodeName: return __MCNameHash((__MCName *)self); case kMCValueTypeCodeNumber: return __MCNumberHash((__MCNumber *)self); case kMCValueTypeCodeString: return __MCStringHash((__MCString *)self); case kMCValueTypeCodeArray: return __MCArrayHash((__MCArray *)self); case kMCValueTypeCodeList: return __MCListHash((__MCList *)self); case kMCValueTypeCodeSet: return __MCSetHash((__MCSet *)self); case kMCValueTypeCodeData: return __MCDataHash((__MCData*) self); case kMCValueTypeCodeCustom: return ((__MCCustomValue *)self) -> callbacks -> hash(p_value); default: break; } MCAssert(false); return 0; }
void *android_font_create(const char *name, uint32_t size, bool bold, bool italic) { MCAndroidFont *t_font = nil; if (MCMemoryNew(t_font)) { SkTypeface::Style t_style = SkTypeface::kNormal; if (bold) { if (italic) t_style = SkTypeface::kBoldItalic; else t_style = SkTypeface::kBold; } else if (italic) t_style = SkTypeface::kItalic; // MM-2012-03-06: Check to see if we have a custom font of the given style and name available if (!create_skia_font_face_from_custom_font_name_and_style(name, bold, italic, t_font->sk_typeface)) t_font->sk_typeface = SkTypeface::CreateFromName(name, t_style); MCAssert(t_font->sk_typeface != NULL); t_font->size = size; } return t_font; }
static bool __MCValueRehashUniqueValues(index_t p_new_item_count) { // Get the current capacity index. uindex_t t_new_capacity_idx; t_new_capacity_idx = s_unique_value_capacity_idx; if (p_new_item_count != 0) { // If we are shrinking we just shrink down to the level needed by the currently // used buckets. if (p_new_item_count < 0) p_new_item_count = 0; // Work out the smallest possible capacity greater than the requested capacity. uindex_t t_new_capacity_req; t_new_capacity_req = s_unique_value_count + p_new_item_count; for(t_new_capacity_idx = 0; t_new_capacity_idx < 64; t_new_capacity_idx++) if (t_new_capacity_req <= __kMCValueHashTableCapacities[t_new_capacity_idx]) break; } // Fetch the old capacity and table. uindex_t t_old_capacity; __MCUniqueValueBucket *t_old_buckets; t_old_capacity = __kMCValueHashTableSizes[s_unique_value_capacity_idx]; t_old_buckets = s_unique_values; // Create the new table. uindex_t t_new_capacity; __MCUniqueValueBucket *t_new_buckets; t_new_capacity = __kMCValueHashTableSizes[t_new_capacity_idx]; if (!MCMemoryNewArray(t_new_capacity, t_new_buckets)) return false; // Update the vars. s_unique_value_capacity_idx = t_new_capacity_idx; s_unique_values = t_new_buckets; // Now rehash the values from the old table. for(uindex_t i = 0; i < t_old_capacity; i++) { if (t_old_buckets[i] . value != UINTPTR_MIN && t_old_buckets[i] . value != UINTPTR_MAX) { uindex_t t_target_slot; t_target_slot = __MCValueFindUniqueValueBucketAfterRehash((__MCValue *)t_old_buckets[i] . value, t_old_buckets[i] . hash); // This assertion should never trigger - something is very wrong if it does! MCAssert(t_target_slot != UINDEX_MAX); s_unique_values[t_target_slot] . hash = t_old_buckets[i] . hash; s_unique_values[t_target_slot] . value = t_old_buckets[i] . value; } } // Delete the old table. MCMemoryDeleteArray(t_old_buckets); // We are done! return true; }
MCValueTypeCode MCValueGetTypeCode(MCValueRef p_value) { __MCValue *self = (__MCValue *)p_value; MCAssert(self != nil); return __MCValueGetTypeCode(self); }
static mailcore::Data * testMessageBuilder() { mailcore::Address * address = new mailcore::Address(); address->setDisplayName(displayName); address->setMailbox(email); address->release(); mailcore::MessageBuilder * msg = new mailcore::MessageBuilder(); msg->header()->setFrom(mailcore::Address::addressWithDisplayName(displayName, email)); mailcore::Array * to = new mailcore::Array(); mailcore::Array * bcc = new mailcore::Array(); to->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Foo Bar"), MCSTR("*****@*****.**"))); to->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Other Recipient"), MCSTR("*****@*****.**"))); bcc->addObject(mailcore::Address::addressWithDisplayName(MCSTR("Hidden Recipient"), MCSTR("*****@*****.**"))); msg->header()->setTo(to); msg->header()->setBcc(bcc); to->release(); bcc->release(); MCAssert(msg->header()->allExtraHeadersNames()->count() == 0); msg->header()->setExtraHeader(MCSTR("X-Custom-Header"), MCSTR("Custom Header Value")); msg->header()->setSubject(MCSTR("Mon projet d'été")); msg->setHTMLBody(MCSTR("<div>Hello <img src=\"cid:1234\"></div>")); msg->addAttachment(mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("first-filename"))); msg->addAttachment(mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("second-filename"))); mailcore::Attachment * attachment = mailcore::Attachment::attachmentWithContentsOfFile(MCSTR("third-image-attachment")); attachment->setContentID(MCSTR("1234")); msg->addRelatedAttachment(attachment); mailcore::Data * data = msg->data(); MCLog("%s", data->bytes()); mailcore::MessageBuilder * msg2 = new mailcore::MessageBuilder(msg); mailcore::String *htmlBody = msg->htmlBody(); mailcore::String *htmlBody2 = msg2->htmlBody(); MCAssert(htmlBody->isEqual(htmlBody2)); msg->release(); msg2->release(); return data; }
bool MCValueIsEqualTo(MCValueRef p_value, MCValueRef p_other_value) { __MCValue *self = (__MCValue *)p_value; __MCValue *other_self = (__MCValue *)p_other_value; // If the pointers are the same, we are equal. if (self == other_self) return true; // If the typecodes are different, we are not equal. if (__MCValueGetTypeCode(self) != __MCValueGetTypeCode(other_self)) return false; switch(__MCValueGetTypeCode(self)) { // There is only one null value, so if we get here, we are not equal. case kMCValueTypeCodeNull: return false; // Booleans are singletons, so if we get here, we are not equal. case kMCValueTypeCodeBoolean: return false; // Names are singletons, so if we get here, we are not equal. case kMCValueTypeCodeName: return false; // Defer to the number comparison method. case kMCValueTypeCodeNumber: return __MCNumberIsEqualTo((__MCNumber *)self, (__MCNumber *)other_self); // Defer to the string comparison method. case kMCValueTypeCodeString: return __MCStringIsEqualTo((__MCString *)self, (__MCString *)other_self); // Defer to the array comparison method. case kMCValueTypeCodeArray: return __MCArrayIsEqualTo((__MCArray *)self, (__MCArray *)other_self); // Defer to the list comparison method. case kMCValueTypeCodeList: return __MCListIsEqualTo((__MCList *)self, (__MCList *)other_self); case kMCValueTypeCodeSet: return __MCSetIsEqualTo((__MCSet *)self, (__MCSet *)other_self); case kMCValueTypeCodeData: return __MCDataIsEqualTo((__MCData*)self, (__MCData*)other_self); // Defer to the custom comparison method, but only if the callbacks are // the same. case kMCValueTypeCodeCustom: if (((__MCCustomValue *)self) -> callbacks == ((__MCCustomValue *)other_self) -> callbacks) return (((__MCCustomValue *)self) -> callbacks) -> equal(p_value, p_other_value); return false; // Shouldn't happen! default: break; } // We should never get here! MCAssert(false); return false; }
MCValueRef MCValueRetain(MCValueRef p_value) { __MCValue *self = (__MCValue *)p_value; MCAssert(self != nil); self -> references += 1; return self; }
Hashtable *asHashtable( Handle_ptr handle) { assert( 0 != handle); if (!handle->hasType( Handle::ntHASHTABLE)) { throw TypeException( "hashtable", __FILE__, __LINE__); } Hashtable *hashtable = dynamic_cast<Hashtable*>( handle->typeImpl()); MCAssert( 0 != hashtable, "failed to access handle as hashtable"); return hashtable; }
void MCFiberDestroy(MCFiberRef self) { // A fiber can only be destroyed at zero depth. MCAssert(self -> depth == 0); // If the thread is owned by the fiber then wait on it to finish. if (self -> owns_thread && self -> thread != nil) { // A fiber that owns its thread cannot destroy itself. MCAssert(self != s_fiber_current); // Loop until the thread is finished. while(!self -> finished) MCFiberMakeCurrent(self); // Join to the thread. pthread_join(self -> thread, nil); // The thread is now gone. self -> thread = nil; } // Remove the fiber record from the list. if (s_fibers != self) { MCFiber *t_previous; for(t_previous = s_fibers; t_previous -> next != self; t_previous = t_previous -> next) ; t_previous -> next = self -> next; } else s_fibers = self -> next; // Delete the record. MCMemoryDelete(self); // If there are now no fibers, finalize our state. if (s_fibers == nil) MCFiberFinalize(); }
void __MCValueDestroy(__MCValue *self) { if ((self -> flags & kMCValueFlagIsInterred) != 0) __MCValueUninter(self); MCValueTypeCode t_code; t_code = __MCValueGetTypeCode(self); switch(t_code) { case kMCValueTypeCodeNull: case kMCValueTypeCodeBoolean: case kMCValueTypeCodeNumber: break; case kMCValueTypeCodeString: __MCStringDestroy((__MCString *)self); break; case kMCValueTypeCodeName: __MCNameDestroy((__MCName *)self); break; case kMCValueTypeCodeArray: __MCArrayDestroy((__MCArray *)self); break; case kMCValueTypeCodeList: __MCListDestroy((__MCList *)self); break; case kMCValueTypeCodeSet: __MCSetDestroy((__MCSet *)self); break; case kMCValueTypeCodeData: __MCDataDestroy((__MCData *)self); break; case kMCValueTypeCodeCustom: return ((__MCCustomValue *)self) -> callbacks -> destroy(self); default: // Shouldn't get here MCAssert(false); } // MW-2014-03-21: [[ Faster ]] If we are pooling this typecode, and the // pool isn't full, add it to the pool. if (t_code <= kMCValueTypeCodeList && s_value_pools[t_code] . count < 32) { s_value_pools[t_code] . count += 1; *(__MCValue **)self = s_value_pools[t_code] . values; s_value_pools[t_code] . values = self; return; } MCMemoryDelete(self); }
// IM-2014-02-13: [[ StackScale ]] Update to work with MCGRectangles MCGRectangle MCStack::view_constrainstackviewport(const MCGRectangle &p_rect) { // IM-2014-01-16: [[ StackScale ]] stack rect now constrained to min/max size elsewhere MCGRectangle t_stackrect; t_stackrect = p_rect; // MW-2012-10-04: [[ Bug 10436 ]] Make sure we constrain stack size to screen size // if in fullscreen mode. MCGRectangle t_new_rect; if (view_getfullscreen()) { const MCDisplay *t_display; t_display = MCscreen -> getnearestdisplay(MCGRectangleGetIntegerInterior(t_stackrect)); switch (m_view_fullscreenmode) { case kMCStackFullscreenResize: // resize stack to fullscreen rect t_new_rect = MCRectangleToMCGRectangle(MCscreen->fullscreenrect(t_display)); break; case kMCStackFullscreenNoScale: // center rect on screen t_new_rect = MCGRectangleCenterOnRect(t_stackrect, MCRectangleToMCGRectangle(MCscreen->fullscreenrect(t_display))); break; case kMCStackFullscreenExactFit: case kMCStackFullscreenLetterbox: case kMCStackFullscreenNoBorder: case kMCStackFullscreenShowAll: // scaling modes should return the requested stack rect t_new_rect = t_stackrect; break; default: MCAssert(false); } } else { // IM-2014-02-28: [[ Bug 11844 ]] Don't constrain stack rect here unless fullscreen t_new_rect = t_stackrect; } return t_new_rect; }
bool MCGRasterCreateCGDataProvider(const MCGRaster &p_raster, const MCGIntegerRectangle &p_src_rect, bool p_copy, bool p_invert, CGDataProviderRef &r_data_provider, uint32_t &r_stride) { MCAssert(p_src_rect.origin.x >= 0 && p_src_rect.origin.y >= 0); MCAssert(p_src_rect.origin.x + p_src_rect.size.width <= p_raster.width); MCAssert(p_src_rect.origin.y + p_src_rect.size.height <= p_raster.height); bool t_success = true; int32_t t_x, t_y; uint32_t t_width, t_height; t_x = p_src_rect.origin.x; t_y = p_src_rect.origin.y; t_width = p_src_rect.size.width; t_height = p_src_rect.size.height; uint8_t *t_src_ptr = (uint8_t*)MCGRasterGetPixelPtr(p_raster, t_x, t_y); uint32_t t_dst_stride; if (p_invert) p_copy = true; CGDataProviderRef t_data_provider = nil; if (!p_copy) { t_dst_stride = p_raster.stride; t_data_provider = CGDataProviderCreateWithData(nil, t_src_ptr, t_height * p_raster.stride, __CGDataProviderDeallocate); t_success = t_data_provider != nil; if (!t_success) MCMemoryDeallocate(t_src_ptr); } else { uint8_t* t_buffer = nil; t_dst_stride = t_width * sizeof(uint32_t); uindex_t t_buffer_size = t_height * t_dst_stride; t_success = MCMemoryAllocate(t_buffer_size, t_buffer); if (t_success) { int32_t t_src_stride; uint8_t* t_dst_ptr = t_buffer; if (!p_invert) { t_src_stride = p_raster.stride; } else { t_src_ptr += ((int32_t)t_height - 1) * p_raster.stride; t_src_stride = -p_raster.stride; } for (uindex_t y = 0; y < t_height; y++) { MCMemoryCopy(t_dst_ptr, t_src_ptr, t_dst_stride); t_dst_ptr += t_dst_stride; t_src_ptr += t_src_stride; } } if (t_success) { t_data_provider = CGDataProviderCreateWithData(nil, t_buffer, t_buffer_size, __CGDataProviderDeallocate); t_success = t_data_provider != nil; } if (!t_success) MCMemoryDeallocate(t_buffer); } if (t_success) { r_data_provider = t_data_provider; r_stride = t_dst_stride; } return t_success; }
inline void *MCGRasterGetPixelPtr(const MCGRaster &p_raster, uint32_t x, uint32_t y) { MCAssert(x < p_raster.width && y < p_raster.height); return (uint8_t*)p_raster.pixels + y * p_raster.stride + x * sizeof(uint32_t); }
NodeValue::~NodeValue() { //FIXME: should explicit deallocation be allowed for shared instances? MCAssert( 1 >= m_refcount, "destroying NodeValue instance with refcount > 0"); }
std::ostream & operator<<( std::ostream &os, const Handle &h) { MCAssert( 0 != &h && 0 != &os, "trying to print (null) handle"); MCAssert( 0 != &os, "trying to print on (null) stream"); #if defined( DEBUG) && DEBUG > 4 std::cerr << "operator<<( ostream &, const Handle &): " << typetagToString( h.m_nodetype) << endl; #endif int i; switch( h.m_nodetype) { case Handle::ntEMPTY: throw InternalInconsistency( "access to empty memory cell", __FILE__, __LINE__); case Handle::ntINTEGER: return os << h.val.m_intValue; case Handle::ntDOUBLE: return os << h.val.m_dblValue; case Handle::ntBOOLEAN: if (h.val.m_boolValue) return os << "#t"; else return os << "#f"; case Handle::ntCHARACTER: return os << static_cast<char>( h.val.m_intValue); case Handle::ntCONS: if (h.isNilRep()) return os << "nil"; else { return printList( &h, os); } case Handle::ntAVECTOR: os << "#("; for (i=0; i<h.val.m_avector.length; ++i) os << ' ' << h.val.m_avector.data[i]; return os << ')'; case Handle::ntSTRING: case Handle::ntSYMBOL: case Handle::ntKEYWORD: case Handle::ntARRAY: case Handle::ntOBJECT: case Handle::ntPORT: case Handle::ntCLOSURE: case Handle::ntHASHTABLE: case Handle::ntSET: h.val.m_value->printToStream( os); return os; case Handle::ntCFUNC: return os << "#<builtin@" << &h << '>'; } MCAssertNotReached( os); return os; }
bool MCImageEncodeGIF(MCImageIndexedBitmap *p_indexed, IO_handle p_stream, uindex_t &r_bytes_written) { bool t_success = true; int32_t t_transparent = -1; uindex_t t_palette_size; uindex_t t_depth; t_depth = GifBitSize(p_indexed->palette_size); // GIF requires palette size to be 2^depth t_palette_size = 1 << t_depth; int t_err = 0; GifFileType *t_gif = nil; ColorMapObject *t_colormap = nil; MCGIFWriteContext t_context; t_context.stream = p_stream; t_context.byte_count = 0; t_success = nil != (t_gif = EGifOpen(&t_context, gif_writeFunc, &t_err)); if (t_success) t_success = nil != (t_colormap = GifMakeMapObject(t_palette_size, nil)); if (t_success) { for (uindex_t i = 0; i < p_indexed->palette_size; i++) { t_colormap->Colors[i].Red = p_indexed->palette[i].red; t_colormap->Colors[i].Green = p_indexed->palette[i].green; t_colormap->Colors[i].Blue = p_indexed->palette[i].blue; } for (uindex_t i = p_indexed->palette_size; i < t_palette_size; i++) { t_colormap->Colors[i].Red = t_colormap->Colors[i].Green = t_colormap->Colors[i].Blue = 0; } if (MCImageIndexedBitmapHasTransparency(p_indexed)) { t_transparent = p_indexed->transparent_index; t_colormap->Colors[t_transparent].Red = t_colormap->Colors[t_transparent].Green = t_colormap->Colors[t_transparent].Blue = 0xFF; } t_success = GIF_OK == EGifPutScreenDesc(t_gif, p_indexed->width, p_indexed->height, t_depth, 0, t_colormap); } if (t_success) { if (t_transparent != -1) { GraphicsControlBlock t_gcb; MCMemoryClear(&t_gcb, sizeof(t_gcb)); t_gcb.TransparentColor = t_transparent; GifByteType t_extension[4]; uindex_t t_extension_size; t_extension_size = EGifGCBToExtension(&t_gcb, t_extension); // Should always be 4 bytes MCAssert(t_extension_size == sizeof(t_extension)); t_success = GIF_OK == EGifPutExtension(t_gif, GRAPHICS_EXT_FUNC_CODE, sizeof(t_extension), t_extension); } } if (t_success) t_success = GIF_OK == EGifPutImageDesc(t_gif, 0, 0, p_indexed->width, p_indexed->height, false, nil); for (uindex_t y = 0; t_success && y < p_indexed->height; y++) t_success = GIF_OK == EGifPutLine(t_gif, (uint8_t*)p_indexed->data + y * p_indexed->stride, p_indexed->width); int t_error_code; if (GIF_ERROR == EGifCloseFile(t_gif, &t_error_code)) t_success = false; GifFreeMapObject(t_colormap); if (t_success) r_bytes_written = t_context.byte_count; return t_success; }
void MCGCacheTableSet(MCGCacheTableRef self, void *p_key, uint32_t p_key_length, void *p_value, uint32_t p_value_length) { if (self == NULL) return; MCAssert(sizeof(uintptr_t) >= p_value_length); if (self -> bytes_used >= self -> max_bytes) { uindex_t t_discard_bucket; t_discard_bucket = rand() % self -> total_buckets; while (self -> bytes_used >= self -> max_bytes) { while (self -> pairs[t_discard_bucket] . key == NULL) { t_discard_bucket++; if (t_discard_bucket >= self -> total_buckets) t_discard_bucket -= self -> total_buckets; } MCGCacheTableDiscardPair(self, t_discard_bucket); //MCLog("MCGCacheTableSet: Max bytes reached. Hash %d discarded.", t_discard_bucket); } } if (self -> used_buckets >= self -> max_occupancy) { uindex_t t_discard_bucket; t_discard_bucket = rand() % self -> total_buckets; while (self -> pairs[t_discard_bucket] . key == NULL) { t_discard_bucket++; if (t_discard_bucket >= self -> total_buckets) t_discard_bucket -= self -> total_buckets; } MCGCacheTableDiscardPair(self, t_discard_bucket); //MCLog("MCGCacheTableSet: Max occupancy reached. Hash %d discarded.", t_discard_bucket); } hash_t t_hash; t_hash = MCGHashBytes(p_key, p_key_length); uindex_t t_target_bucket; t_target_bucket = MCGCacheTableLookup(self, p_key, p_key_length, t_hash); if (t_target_bucket == UINDEX_MAX) { t_target_bucket = t_hash % self -> total_buckets; MCMemoryDelete(self -> pairs[t_target_bucket] . key); self -> bytes_used -= self -> pairs[t_target_bucket] . key_length; self -> pairs[t_target_bucket] . hash = t_hash; self -> pairs[t_target_bucket] . key = p_key; self -> pairs[t_target_bucket] . key_length = p_key_length; self -> pairs[t_target_bucket] . value = NULL; MCMemoryCopy(&self -> pairs[t_target_bucket] . value, p_value, p_value_length); self -> bytes_used += p_key_length; //MCLog("MCGCacheTableSet: Cache table overflow. Hash %d thrown out.", t_target_bucket); } else if (self -> pairs[t_target_bucket] . value != NULL) { MCMemoryDelete(p_key); self -> pairs[t_target_bucket] . value = NULL; MCMemoryCopy(&self -> pairs[t_target_bucket] . value, p_value, p_value_length); //MCLog("MCGCacheTableSet: Cache table overwrite. Hash %d rewritten.", t_target_bucket); } else { self -> pairs[t_target_bucket] . hash = t_hash; self -> pairs[t_target_bucket] . key = p_key; self -> pairs[t_target_bucket] . key_length = p_key_length; MCMemoryCopy(&self -> pairs[t_target_bucket] . value, p_value, p_value_length); self -> bytes_used += p_key_length; self -> used_buckets++; //MCLog("MCGCacheTableSet: Cache table write. Hash %d written.", t_target_bucket); } }