bool MCFontUnload(MCStringRef p_path) { MCLoadedFont *t_prev_font; t_prev_font = nil; for(MCLoadedFont *t_font = s_loaded_fonts; t_font != nil; t_font = t_font -> next) { if (MCStringIsEqualTo(t_font -> path, p_path, kMCStringOptionCompareCaseless)) { if (!MCscreen -> unloadfont(p_path, t_font -> is_global, t_font -> handle)) return false; if (t_prev_font != nil) t_prev_font -> next = t_font -> next; else s_loaded_fonts = t_font -> next; MCMemoryDelete(t_font -> path); MCMemoryDelete(t_font); // MW-2013-09-11: [[ DynamicFonts ]] Make sure the engine reloads all fonts. MCFontRemap(); MCstacks -> purgefonts(); break; } t_prev_font = t_font; } return true; }
static bool MCS_loadurl_callback(void *p_context, MCSystemUrlStatus p_status, const void *p_data) { MCSLoadUrlState *context; context = static_cast<MCSLoadUrlState *>(p_context); context -> status = p_status; if (p_status == kMCSystemUrlStatusError) MCMemoryDelete(context->data.bytes); else if (p_status == kMCSystemUrlStatusLoading) { const MCString *t_data = static_cast<const MCString*>(p_data); MCMemoryReallocate(context->data.bytes, context->data.size + t_data->getlength(), context->data.bytes); MCMemoryCopy(static_cast<uint8_t*>(context->data.bytes) + context->data.size, t_data->getstring(), t_data->getlength()); context->data.size += t_data->getlength(); } send_url_progress(context -> object, p_status, context -> url, context -> data . size, context -> total, (const char *)p_data); if (p_status == kMCSystemUrlStatusError || p_status == kMCSystemUrlStatusFinished) { MCUrlLoadEvent *t_event; t_event = MCUrlLoadEvent::CreateUrlLoadEvent(context->object, context->message, context->url, p_status, context->data.bytes, context->data.size, static_cast<const char *>(p_data)); if (t_event) MCEventQueuePostCustom(t_event); context->object->Release(); MCCStringFree(context->url); MCNameDelete(context->message); MCMemoryDelete(context); } return true; }
static void remove_object_listener_from_list(MCObjectListener *&p_listener, MCObjectListener *p_prev_listener) { MCObjectListenerTarget *t_target; t_target = nil; MCObjectListenerTarget *t_next_target; t_next_target = nil; for (t_target = p_listener -> targets; t_target != nil; t_target = t_next_target) { t_next_target = t_target -> next; t_target -> target -> Release(); MCMemoryDelete(t_target); } if (p_listener -> object -> Exists()) p_listener -> object -> Get() -> unlisten(); p_listener -> object -> Release(); if (p_prev_listener != nil) p_prev_listener -> next = p_listener -> next; else s_object_listeners = p_listener -> next; // MW-2013-08-27: [[ Bug 11126 ]] If this pointer is going away, make sure we fetch the next // listener into the static. if (s_next_listener_to_process == p_listener) s_next_listener_to_process = p_listener -> next; MCMemoryDelete(p_listener); p_listener = p_prev_listener; }
void MCSystemSensorFinalize(void) { /* UNCHECKED */ MCMemoryDelete(s_acceleration_reading); /* UNCHECKED */ MCMemoryDelete(s_location_reading); /* UNCHECKED */ MCMemoryDelete(s_heading_reading); /* UNCHECKED */ MCMemoryDelete(s_rotation_rate_reading); }
Exec_stat MCFontUnload(MCExecPoint& ep, const char *p_path) { MCLoadedFont *t_prev_font; t_prev_font = nil; for(MCLoadedFont *t_font = s_loaded_fonts; t_font != nil; t_font = t_font -> next) { if (MCU_strcasecmp(t_font -> path, p_path) == 0) { if (!MCscreen -> unloadfont(p_path, t_font -> is_global, t_font -> handle)) return ES_ERROR; if (t_prev_font != nil) t_prev_font -> next = t_font -> next; else s_loaded_fonts = t_font -> next; MCMemoryDelete(t_font -> path); MCMemoryDelete(t_font); // MW-2013-09-11: [[ DynamicFonts ]] Make sure the engine reloads all fonts. MCFontRemap(); MCstacks -> purgefonts(); break; } t_prev_font = t_font; } return ES_NORMAL; }
void MCGCacheTableDestroy(MCGCacheTableRef self) { if (self == NULL) return; if (self -> pairs != NULL) { for (uindex_t i = 0; i < self -> total_buckets; i++) MCMemoryDelete(self -> pairs[i] . key); MCMemoryDeleteArray(self -> pairs); } MCMemoryDelete(self); }
bool MCPatternCreate(MCGImageRef p_image, MCGFloat p_scale, MCPatternRef &r_pattern) { bool t_success; t_success = true; MCPatternRef t_pattern; t_pattern = nil; t_success = MCMemoryNew(t_pattern); if (t_success) { t_pattern -> image = MCGImageRetain(p_image); t_pattern -> scale = p_scale; t_pattern -> references = 1; r_pattern = t_pattern; } else { MCMemoryDelete(t_pattern); } return t_success; }
bool MCGImageCreateWithSkBitmap(const SkBitmap &p_bitmap, MCGImageRef &r_image) { bool t_success; t_success = true; __MCGImage *t_image; t_image = nil; if (t_success) t_success = MCMemoryNew(t_image); SkBitmap *t_bitmap; t_bitmap = nil; if (t_success) { t_bitmap = new SkBitmap(p_bitmap); t_bitmap -> lockPixels(); t_success = nil != t_bitmap; } if (t_success) { t_image -> bitmap = t_bitmap; t_image -> is_valid = true; t_image -> references = 1; r_image = t_image; } else { if (t_bitmap != nil) delete t_bitmap; MCMemoryDelete(t_image); } return t_success; }
void MCSystemRequestUserAttention(void) { if (s_bounce_nmr != nil) MCSystemCancelRequestUserAttention(); bool t_success; t_success = true; if (t_success) t_success = MCMemoryNew(s_bounce_nmr); if (t_success) { s_bounce_nmr -> nmMark = 1; s_bounce_nmr -> qType = nmType; if (NMInstall(s_bounce_nmr) != noErr) t_success = false; } if (!t_success) { MCMemoryDelete(s_bounce_nmr); s_bounce_nmr = nil; } }
void MCTileCacheSoftwareCompositor_Cleanup(void *p_context) { MCTileCacheSoftwareCompositorContext *self; self = (MCTileCacheSoftwareCompositorContext *)p_context; MCMemoryDeallocate(self -> tile_row); MCMemoryDelete(self); }
void android_font_destroy(void *font) { MCAndroidFont *t_font = (MCAndroidFont*)font; if (t_font != nil && t_font->sk_typeface != nil) t_font->sk_typeface->unref(); MCMemoryDelete(font); }
void MCGRegionDestroy(MCGRegionRef p_region) { if (p_region == nil) return; MCMemoryDelete(p_region); }
void MCS_loadurl(MCObject *p_object, const char *p_url, const char *p_message) { bool t_success = true; MCSLoadUrlState *t_state = nil; char *t_processed = nil; MCNameRef t_message = nil; t_success = MCMemoryNew(t_state) && MCSystemProcessUrl(p_url, kMCSystemUrlOperationStrip, t_processed) && MCNameCreateWithCString(p_message, t_message); if (t_success) { t_state->url = t_processed; t_state->message = t_message; t_state->status = kMCSystemUrlStatusNone; t_state->object = p_object -> gethandle(); t_state->data . bytes = nil; t_state->data . size = 0; t_success = MCSystemLoadUrl(t_processed, MCS_loadurl_callback, t_state); } if (t_success) MCresult->clear(); else { MCCStringFree(t_processed); MCNameDelete(t_message); MCMemoryDelete(t_state); MCurlresult -> clear(); MCresult->sets("error: load URL failed"); } }
static void MCTextLayoutLinkedFontDestroy(MCTextLayoutLinkedFont *self) { for(uint32_t i = 0; i < self -> entry_count; i++) MCCStringFree(self -> entries[i] . face); MCMemoryDeleteArray(self -> entries); MCCStringFree(self -> name); MCMemoryDelete(self); }
void deleteUrlInfo(MCUrlInfo *p_info) { if (p_info != nil) { MCCStringFree(p_info->url); MCMemoryDelete(p_info); } }
static bool load_custom_font_file_into_buffer_from_path(const char *p_path, char *&r_buffer, uint32_t &r_size) { bool t_success; t_success = true; char *t_font_path; t_font_path = nil; if (t_success) t_success = MCCStringFormat(t_font_path, "%s/%s%s", MCcmd, s_font_folder, p_path); if (t_success) t_success = MCS_exists(t_font_path, true); IO_handle t_font_file_handle; t_font_file_handle = nil; if (t_success) { t_font_file_handle = MCS_open(t_font_path, IO_READ_MODE, false, false, 0); t_success = t_font_file_handle != nil; } uint32_t t_file_size; t_file_size = 0; char *t_buffer; t_buffer = nil; if (t_success) { t_file_size = MCS_fsize(t_font_file_handle); t_success = MCMemoryAllocate(t_file_size + 1, t_buffer); } if (t_success) { IO_stat t_read_stat; uint32_t t_bytes_read; t_bytes_read = 0; while (t_success && t_bytes_read < t_file_size) { uint32_t t_count; t_count = t_file_size - t_bytes_read; t_read_stat = MCS_read(t_buffer + t_bytes_read, 1, t_count, t_font_file_handle); t_bytes_read += t_count; t_success = (t_read_stat == IO_NORMAL || (t_read_stat == IO_EOF && t_bytes_read == t_file_size)); } } if (t_success) { r_buffer = t_buffer; r_size = t_file_size; } else /*UNCHECKED */ MCMemoryDelete(t_buffer); /*UNCHECKED */ MCCStringFree(t_font_path); return t_success; }
void MCTileCacheCoreGraphicsCompositor_Cleanup(void *p_context) { MCTileCacheCoreGraphicsCompositorContext *self; self = (MCTileCacheCoreGraphicsCompositorContext *)p_context; CGColorSpaceRelease(self -> colorspace); MCMemoryDelete(self); }
void MCSystemCancelRequestUserAttention(void) { if (s_bounce_nmr != nil) { NMRemove(s_bounce_nmr); MCMemoryDelete(s_bounce_nmr); s_bounce_nmr = nil; } }
static void MCTextLayoutFontDestroy(MCTextLayoutFont *self) { if (self == nil) return; DeleteObject(self -> handle); ScriptFreeCache(&self -> cache); MCMemoryDelete(self); }
static void delete_custom_font(MCAndroidCustomFont *p_font) { if (p_font != nil) { /*UNCHECKED */ MCCStringFree(p_font->path); /*UNCHECKED */ MCCStringFree(p_font->name); /*UNCHECKED */ MCCStringFree(p_font->family); /*UNCHECKED */ MCMemoryDelete(p_font); } }
static void MCEventQueueDestroyEvent(MCEvent *p_event) { if (p_event -> type == kMCEventTypeImeCompose) MCMemoryDeleteArray(p_event -> ime . compose . chars); #ifdef _MOBILE if (p_event -> type == kMCEventTypeCustom) p_event -> custom . event -> Destroy(); #endif MCMemoryDelete(p_event); }
static void remove_object_listener_target_from_list(MCObjectListenerTarget *&p_target, MCObjectListenerTarget *p_prev_target, MCObjectListener* &p_listener, MCObjectListener* p_prev_listener) { p_target -> target -> Release(); if (p_prev_target != nil) p_prev_target -> next = p_target -> next; else p_listener -> targets = p_target -> next; if (p_listener -> targets == nil) remove_object_listener_from_list(p_listener, p_prev_listener); MCMemoryDelete(p_target); p_target = p_prev_target; }
static inline void MCGCacheTableDiscardPair(MCGCacheTableRef self, uindex_t p_pair) { self -> used_buckets--; self -> bytes_used -= self -> pairs[p_pair] . key_length; MCMemoryDelete(self -> pairs[p_pair] . key); self -> pairs[p_pair] . hash = 0; self -> pairs[p_pair] . key_length = 0; self -> pairs[p_pair] . key = NULL; self -> pairs[p_pair] . value = NULL; }
static void MCGImageDestroy(MCGImageRef self) { if (self != NULL) { if (self -> bitmap != NULL) { self -> bitmap -> unlockPixels(); delete self -> bitmap; } MCMemoryDelete(self); } }
void MCPatternRelease(MCPatternRef p_pattern) { if (p_pattern == nil) return; p_pattern->references--; if (p_pattern->references == 0) { MCGImageRelease(p_pattern->image); MCMemoryDelete(p_pattern); } }
void MCUrlLoadEvent::Destroy(void) { MCCStringFree(m_url); MCNameDelete(m_message); if (m_status == kMCSystemUrlStatusFinished) MCMemoryDelete(m_data.bytes); else if (m_status == kMCSystemUrlStatusError) MCCStringFree(m_error); if (m_object != nil) m_object->Release(); delete this; }
void MCSessionDisposeSession(MCSession *p_session) { if (p_session == NULL) return; MCCStringFree(p_session->id); MCCStringFree(p_session->ip); MCCStringFree(p_session->filename); MCMemoryDeallocate(p_session->data); MCMemoryDelete(p_session); }
void MCScreenDC::destroycolortransform(MCColorTransformRef transform) { MCWindowsColorTransform *t_transform; t_transform = (MCWindowsColorTransform *)transform; if (t_transform == nil) return; if (t_transform -> transform != nil) DeleteColorTransform(t_transform -> transform); MCMemoryDelete(t_transform); }
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); }
static void remove_object_listener_from_list(MCObjectListener *&p_listener, MCObjectListener *p_prev_listener) { MCObjectListenerTarget *t_target; t_target = nil; MCObjectListenerTarget *t_next_target; t_next_target = nil; for (t_target = p_listener -> targets; t_target != nil; t_target = t_next_target) { t_next_target = t_target -> next; t_target -> target -> Release(); MCMemoryDelete(t_target); } if (p_listener -> object -> Exists()) p_listener -> object -> Get() -> unlisten(); p_listener -> object -> Release(); if (p_prev_listener != nil) p_prev_listener -> next = p_listener -> next; else s_object_listeners = p_listener -> next; MCMemoryDelete(p_listener); p_listener = p_prev_listener; }