Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 524d25f

Browse files
committed
Removed some MCStringGetCString() calls
1 parent 2933297 commit 524d25f

File tree

8 files changed

+34
-41
lines changed

8 files changed

+34
-41
lines changed

engine/include/customprinter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ struct MCCustomPrinterDocument
3939
const char *filename;
4040

4141
uint32_t option_count;
42-
const char * const *option_keys;
43-
const char * const *option_values;
42+
MCStringRef const *option_keys;
43+
MCStringRef const *option_values;
4444
};
4545

4646
struct MCCustomPrinterPage

engine/src/block.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,11 +2331,9 @@ uint32_t measure_nameref(MCNameRef p_name)
23312331

23322332
static uint32_t measure_stringref(MCStringRef p_string)
23332333
{
2334-
const char *t_cstring;
2335-
t_cstring = MCStringGetCString(p_string);
2336-
if (*t_cstring == '\0')
2334+
if (MCStringIsEmpty(p_string))
23372335
return 2;
2338-
return 2 + MCU_min(strlen(t_cstring) + 1, MAXUINT2);
2336+
return 2 + MCU_min(MCStringGetLength(p_string) + 1, MAXUINT2);
23392337
}
23402338

23412339
// MW-2012-03-04: [[ StackFile5500 ]] Compute the number of bytes the attributes will

engine/src/customprinter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,21 +1118,21 @@ const char *MCCustomPrinterDevice::Error(void) const
11181118
struct convert_options_array_t
11191119
{
11201120
uindex_t index;
1121-
char **option_keys;
1122-
char **option_values;
1121+
MCStringRef *option_keys;
1122+
MCStringRef *option_values;
11231123
};
11241124

11251125
static bool convert_options_array(void *p_context, MCArrayRef p_array, MCNameRef p_key, MCValueRef p_value)
11261126
{
11271127
convert_options_array_t *ctxt;
11281128
ctxt = (convert_options_array_t *)p_context;
11291129

1130-
MCExecPoint ep(nil, nil, nil);
1131-
if (!MCCStringClone(MCStringGetCString(MCNameGetString(p_key)), ctxt -> option_keys[ctxt -> index]))
1132-
return false;
1133-
if (!ep . setvalueref(p_value))
1130+
//MCExecPoint ep(nil, nil, nil);
1131+
if (!MCStringCopy(MCNameGetString(p_key), ctxt -> option_keys[ctxt -> index]))
11341132
return false;
1135-
if (!MCCStringClone(ep . getcstring(), ctxt -> option_values[ctxt -> index]))
1133+
//if (!ep . setvalueref(p_value))
1134+
//return false;
1135+
if (!MCStringCopy((MCStringRef)p_value, ctxt -> option_values[ctxt -> index]))
11361136
return false;
11371137
ctxt -> index += 1;
11381138
return true;
@@ -1153,7 +1153,7 @@ MCPrinterResult MCCustomPrinterDevice::Start(const char *p_title, MCArrayRef p_o
11531153
t_document . filename = MCprinter -> GetDeviceOutputLocation();
11541154

11551155
// Extract the option strings
1156-
char **t_option_keys, **t_option_values;
1156+
MCStringRef *t_option_keys, *t_option_values;
11571157
uint32_t t_option_count;
11581158
t_option_keys = t_option_values = nil;
11591159
t_option_count = 0;
@@ -1187,8 +1187,8 @@ MCPrinterResult MCCustomPrinterDevice::Start(const char *p_title, MCArrayRef p_o
11871187
if (t_option_values != nil)
11881188
for(uint32_t i = 0; i < t_document . option_count; i++)
11891189
{
1190-
MCCStringFree(t_option_keys[i]);
1191-
MCCStringFree(t_option_values[i]);
1190+
MCValueRelease(t_option_keys[i]);
1191+
MCValueRelease(t_option_values[i]);
11921192
}
11931193

11941194
MCMemoryDeleteArray(t_option_values);

engine/src/exec-interface-object.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,14 +3055,13 @@ void MCObject::SetProperties(MCExecContext& ctxt, uint32_t part, MCArrayRef prop
30553055
MCValueRef t_value;
30563056
while(MCArrayIterate(props, t_iterator, t_key, t_value))
30573057
{
3058-
MCScriptPoint sp(MCStringGetCString(MCNameGetString(t_key)));
3058+
MCScriptPoint sp(MCNameGetString(t_key));
30593059
Symbol_type type;
30603060
const LT *te;
30613061
if (sp.next(type) && sp.lookup(SP_FACTOR, te) == PS_NORMAL
30623062
&& te->type == TT_PROPERTY && te->which != P_ID)
30633063
{
3064-
ctxt . GetEP() . setvalueref(t_value);
3065-
setprop(part, (Properties)te->which, ctxt . GetEP(), False);
3064+
setstringprop(ctxt, part, (Properties)te->which, False, (MCStringRef)t_value);
30663065
}
30673066
}
30683067
MCerrorlock--;

engine/src/exec-interface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void MCInterfaceMakeVisualEffectArgument(MCExecContext& ctxt, MCStringRef p_valu
456456
{
457457
if (p_has_id)
458458
{
459-
if (!MCStringFormat(r_arg . value, "id %s", MCStringGetCString(p_key)))
459+
if (!MCStringFormat(r_arg . value, "id %@", p_key))
460460
{
461461
ctxt . Throw();
462462
return;
@@ -4262,11 +4262,11 @@ void MCInterfaceExecVisualEffect(MCExecContext& ctxt, MCInterfaceVisualEffect p_
42624262
effectptr -> direction = p_effect . direction;
42634263
effectptr -> speed = p_effect . speed;
42644264
effectptr -> image = p_effect . image;
4265-
effectptr -> name = strclone(MCStringGetCString(p_effect . name));
4265+
effectptr -> name = MCValueRetain(p_effect . name);
42664266
if (MCStringGetLength(p_effect . sound) == 0)
42674267
effectptr -> sound = NULL;
42684268
else
4269-
effectptr -> sound = strclone(MCStringGetCString(p_effect . sound));
4269+
effectptr -> sound = MCValueRetain(p_effect . sound);
42704270

42714271
MCEffectArgument *t_arguments = nil;
42724272
for (uindex_t i = 0; i < p_effect . nargs; i++)
@@ -4275,8 +4275,8 @@ void MCInterfaceExecVisualEffect(MCExecContext& ctxt, MCInterfaceVisualEffect p_
42754275
MCEffectArgument *t_kv;
42764276
t_kv = new MCEffectArgument;
42774277
t_kv -> next = t_arguments;
4278-
t_kv -> key = strclone(MCStringGetCString(t_arg . key));
4279-
t_kv -> value = strclone(MCStringGetCString(t_arg . value));
4278+
t_kv -> key = MCValueRetain(t_arg . key);
4279+
t_kv -> value = MCValueRetain(t_arg . value);
42804280
t_arguments = t_kv;
42814281
t_arg = p_effect . arguments[i+1];
42824282
}

engine/src/stacke.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,14 @@ void MCStack::effectrect(const MCRectangle& p_area, Boolean& r_abort)
241241
if (t_effects -> sound != NULL)
242242
{
243243
MCAudioClip *acptr;
244-
MCAutoStringRef t_sound;
245-
/* UNCHECKED */ MCStringCreateWithCString(t_effects->sound, &t_sound);
246-
if ((acptr = (MCAudioClip *)getobjname(CT_AUDIO_CLIP, *t_sound)) == NULL)
244+
if ((acptr = (MCAudioClip *)getobjname(CT_AUDIO_CLIP, t_effects->sound)) == NULL)
247245
{
248246
IO_handle stream;
249-
MCAutoStringRef t_sound;
250-
/* UNCHECKED */ MCStringCreateWithCString(t_effects->sound, &t_sound);
251-
if ((stream = MCS_open(*t_sound, kMCSOpenFileModeRead, True, False, 0)) != NULL)
247+
if ((stream = MCS_open(t_effects->sound, kMCSOpenFileModeRead, True, False, 0)) != NULL)
252248
{
253249
acptr = new MCAudioClip;
254250
acptr->setdisposable();
255-
if (!acptr->import(*t_sound, stream))
251+
if (!acptr->import(t_effects->sound, stream))
256252
{
257253
delete acptr;
258254
acptr = NULL;
@@ -281,12 +277,12 @@ void MCStack::effectrect(const MCRectangle& p_area, Boolean& r_abort)
281277
if (t_effects -> type != VE_PLAIN)
282278
{
283279
#ifdef _MAC_DESKTOP
284-
if (t_effects -> type == VE_UNDEFINED && MCCoreImageEffectBegin(t_effects -> name, t_dst_drawable, t_start_image, t_end_image, t_dst_effect_area, t_effects -> arguments))
280+
if (t_effects -> type == VE_UNDEFINED && MCCoreImageEffectBegin(MCStringGetCString(t_effects -> name), t_dst_drawable, t_start_image, t_end_image, t_dst_effect_area, t_effects -> arguments))
285281
t_effects -> type = VE_CIEFFECT;
286282
else
287283
#endif
288284
#ifdef FEATURE_QUICKTIME
289-
if (MCQTEffectBegin(t_effects -> type, t_effects -> name, t_effects -> direction, t_dst_drawable, t_start_image, t_end_image, t_dst_effect_area))
285+
if (MCQTEffectBegin(t_effects -> type, MCStringGetCString(t_effects -> name), t_effects -> direction, t_dst_drawable, t_start_image, t_end_image, t_dst_effect_area))
290286
t_effects -> type = VE_QTEFFECT;
291287
#endif
292288
}

engine/src/visual.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ MCEffectList::~MCEffectList()
3737
{
3838
MCEffectArgument *t_kv = arguments;
3939
arguments = t_kv -> next;
40-
delete[] t_kv -> key;
41-
delete[] t_kv -> value;
40+
MCValueRelease(t_kv -> key);
41+
MCValueRelease(t_kv -> value);
4242
delete t_kv;
4343
}
4444

45-
delete name;
46-
delete sound;
45+
MCValueRelease(name);
46+
MCValueRelease(sound);
4747
}
4848

4949
MCVisualEffect::~MCVisualEffect()

engine/src/visual.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ class MCVisualEffect : public MCStatement
6060
struct MCEffectArgument
6161
{
6262
MCEffectArgument *next;
63-
char *key;
64-
char *value;
63+
MCStringRef key;
64+
MCStringRef value;
6565
};
6666

6767
class MCEffectList
6868
{
6969
public:
7070
MCEffectList *next;
71-
char *name;
72-
char *sound;
71+
MCStringRef name;
72+
MCStringRef sound;
7373
MCEffectArgument *arguments;
7474

7575
Visual_effects type;

0 commit comments

Comments
 (0)