@@ -241,7 +241,7 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
241241
242242 // Add any redirects
243243 if (t_success)
244- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params.redirects ) && t_success; i++)
244+ for (uindex_t i = 0 ; i < MCArrayGetCount (p_params.redirects ) && t_success; i++)
245245 {
246246 MCValueRef t_val;
247247 /* UNCHECKED */ MCArrayFetchValueAtIndex (p_params.redirects , i + 1 , t_val);
@@ -252,14 +252,11 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
252252
253253 // Add all the modules before the stacks, this is so that widgets can resolve
254254 // themselves on load.
255- uindex_t t_module_file_count;
256- MCDeployFileRef *t_module_files;
257- t_module_file_count = 0 ;
258- t_module_files = nil;
255+ MCAutoArray<MCDeployFileRef> t_module_files;
259256 if (t_success)
260- t_success = MCMemoryNewArray (MCArrayGetCount (p_params . modules), t_module_files, t_module_file_count );
257+ t_success = t_module_files . New (MCArrayGetCount (p_params . modules));
261258 if (t_success)
262- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params.modules ) && t_success; i++)
259+ for (uindex_t i = 0 ; i < MCArrayGetCount (p_params.modules ) && t_success; i++)
263260 {
264261 MCValueRef t_module_filename;
265262 /* UNCHECKED */ MCArrayFetchValueAtIndex (p_params .modules , i + 1 , t_module_filename);
@@ -278,11 +275,17 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
278275 t_iterator = 0 ;
279276 while (t_success && MCEngineIterateExtensionFilenames (t_iterator, t_filename))
280277 {
281- t_success = MCMemoryResizeArray (t_module_file_count + 1 , t_module_files, t_module_file_count);
282- if (t_success && !MCDeployFileOpen (t_filename, kMCOpenFileModeRead , t_module_files[t_module_file_count - 1 ]))
278+ MCDeployFileRef t_file;
279+ t_file = nil;
280+ if (t_success &&
281+ !MCDeployFileOpen (t_filename, kMCOpenFileModeRead , t_file))
283282 t_success = MCDeployThrow (kMCDeployErrorNoModule );
284283 if (t_success)
285- t_success = MCDeployCapsuleDefineFromFile (t_capsule, kMCCapsuleSectionTypeModule , t_module_files[t_module_file_count - 1 ]);
284+ t_success = t_module_files . Push (t_file);
285+ if (t_success)
286+ t_success = MCDeployCapsuleDefineFromFile (t_capsule, kMCCapsuleSectionTypeModule , t_file);
287+ if (!t_success && t_file != nil)
288+ MCDeployFileClose (t_file);
286289 }
287290 }
288291
@@ -293,12 +296,11 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
293296 t_success = MCDeployCapsuleDefineFromFile (t_capsule, kMCCapsuleSectionTypeStack , t_stackfile);
294297
295298 // Now we add the auxillary stackfiles, if any
296- MCDeployFileRef *t_aux_stackfiles;
297- t_aux_stackfiles = nil;
299+ MCAutoArray<MCDeployFileRef> t_aux_stackfiles;
298300 if (t_success)
299- t_success = MCMemoryNewArray (MCArrayGetCount (p_params . auxillary_stackfiles), t_aux_stackfiles );
301+ t_success = t_aux_stackfiles . New (MCArrayGetCount (p_params . auxillary_stackfiles));
300302 if (t_success)
301- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params.auxillary_stackfiles ) && t_success; i++)
303+ for (uindex_t i = 0 ; i < MCArrayGetCount (p_params.auxillary_stackfiles ) && t_success; i++)
302304 {
303305 MCValueRef t_val;
304306 /* UNCHECKED */ MCArrayFetchValueAtIndex (p_params.auxillary_stackfiles , i + 1 , t_val);
@@ -310,7 +312,7 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
310312
311313 // Now add the externals, if any
312314 if (t_success)
313- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params.externals ) && t_success; i++)
315+ for (uindex_t i = 0 ; i < MCArrayGetCount (p_params.externals ) && t_success; i++)
314316 {
315317 MCValueRef t_val;
316318 /* UNCHECKED */ MCArrayFetchValueAtIndex (p_params.externals , i + 1 , t_val);
@@ -334,12 +336,10 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
334336 t_success = MCDeployCapsuleGenerate (t_capsule, p_output, t_spill, x_offset);
335337
336338 MCDeployCapsuleDestroy (t_capsule);
337- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params. auxillary_stackfiles ); i++)
339+ for (uindex_t i = 0 ; i < t_aux_stackfiles . Size ( ); i++)
338340 MCDeployFileClose (t_aux_stackfiles[i]);
339- MCMemoryDeleteArray (t_aux_stackfiles);
340- for (uint32_t i = 0 ; i < MCArrayGetCount (p_params.modules ); i++)
341- MCDeployFileClose (t_module_files[i]);
342- MCMemoryDeleteArray (t_module_files);
341+ for (uindex_t i = 0 ; i < t_module_files . Size (); i++)
342+ MCDeployFileClose (t_module_files[i]);
343343 MCDeployFileClose (t_spill);
344344 MCDeployFileClose (t_stackfile);
345345
@@ -441,6 +441,7 @@ bool MCDeployWritePayload(const MCDeployParameters& p_params, bool p_to_network,
441441MCIdeDeploy::MCIdeDeploy (void )
442442{
443443 m_params = NULL ;
444+ m_platform = PLATFORM_NONE ;
444445}
445446
446447MCIdeDeploy::~MCIdeDeploy (void )
@@ -565,6 +566,7 @@ void MCIdeDeploy::exec_ctxt(MCExecContext& ctxt)
565566MCIdeSign::MCIdeSign (void )
566567{
567568 m_params = NULL ;
569+ m_platform = PLATFORM_NONE ;
568570}
569571
570572MCIdeSign::~MCIdeSign (void )
@@ -666,6 +668,7 @@ void MCIdeSign::exec_ctxt(MCExecContext &ctxt)
666668MCIdeDiet::MCIdeDiet (void )
667669{
668670 m_params = NULL ;
671+ m_platform = PLATFORM_NONE ;
669672}
670673
671674MCIdeDiet::~MCIdeDiet (void )
@@ -789,8 +792,11 @@ void MCIdeDmgDump::exec_ctxt(MCExecContext &ctxt)
789792 }
790793 FILE *t_output;
791794 t_output = fopen (" C:\\ Users\\ Mark\\ Desktop\\ dmg.txt" , " w" );
792- MCDeployDmgDump (*temp, stdfile_log, t_output);
793- fclose (t_output);
795+ if (t_output != nil)
796+ {
797+ MCDeployDmgDump (*temp, stdfile_log, t_output);
798+ fclose (t_output);
799+ }
794800 }
795801}
796802
@@ -836,20 +842,15 @@ void MCIdeDmgBuild::exec_ctxt(MCExecContext& ctxt)
836842 return ;
837843 }
838844
839- MCDeployDmgItem *t_items;
840- uint32_t t_item_count;
841- t_items = nil;
842- t_item_count = 0 ;
845+ MCAutoArray<MCDeployDmgItem> t_items;
843846 if (!ctxt . HasError ())
844847 {
845- if (MCMemoryNewArray (MCArrayGetCount (*t_array), t_items))
846- t_item_count = MCArrayGetCount (*t_array);
847- else
848- ctxt . Throw ();
848+ if (!t_items . New (MCArrayGetCount (*t_array)))
849+ ctxt . Throw ();
849850 }
850851
851852 if (!ctxt . HasError ())
852- for (uint32_t i = 0 ; i < t_item_count && !ctxt . HasError (); i++)
853+ for (uindex_t i = 0 ; i < t_items . Size () && !ctxt . HasError (); i++)
853854 {
854855 MCValueRef t_val = nil;
855856 if (!MCArrayFetchValueAtIndex (*t_array, i + 1 , t_val))
@@ -915,8 +916,8 @@ void MCIdeDmgBuild::exec_ctxt(MCExecContext& ctxt)
915916 return ;
916917 }
917918 MCDeployDmgParameters t_params;
918- t_params . items = t_items;
919- t_params . item_count = t_item_count ;
919+ t_params . items = t_items . Ptr () ;
920+ t_params . item_count = t_items . Size () ;
920921 t_params . output = *temp;
921922 if (!MCDeployDmgBuild (t_params))
922923 ctxt . Throw ();
@@ -972,20 +973,18 @@ void MCIdeExtract::exec_ctxt(MCExecContext& ctxt)
972973 MCAutoStringRef t_filename;
973974 if (!ctxt . EvalExprAsStringRef (m_filename, EE_IDE_EXTRACT_BADFILENAME , &t_filename))
974975 return ;
975-
976+
976977 void *t_data;
977978 uint32_t t_data_size;
978979 Exec_stat t_stat;
979- if (!ctxt . HasError ())
980- t_stat = MCDeployExtractMacOSX (*t_filename, *t_segment, *t_section, t_data, t_data_size);
981-
982- if (t_stat == ES_NORMAL )
983- {
980+ t_stat = MCDeployExtractMacOSX (*t_filename, *t_segment, *t_section, t_data, t_data_size);
981+ if (t_stat == ES_NORMAL )
982+ {
984983 MCAutoStringRef t_string;
985984 /* UNCHECKED */ MCStringCreateWithNativeChars ((const char_t *)t_data, t_data_size, &t_string);
986985 ctxt . SetItToValue (*t_string);
987- }
988- else
986+ }
987+ else
989988 ctxt . SetItToEmpty ();
990989}
991990
0 commit comments