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

Commit 3c55877

Browse files
committed
libfoundation: Add type checks to exported MCList functions.
1 parent fa1e4e3 commit 3c55877

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

libfoundation/src/foundation-list.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ bool MCListCreateMutable(MCStringRef p_delimiter, MCListRef& r_list)
4848

4949
bool MCListAppend(MCListRef self, MCValueRef p_value)
5050
{
51+
__MCAssertIsList(self);
52+
MCAssert(nil != p_value);
53+
5154
bool t_first = self->buffer == nil;
5255
if (t_first)
5356
if (!MCStringCreateMutable(0, self -> buffer))
@@ -88,7 +91,7 @@ bool MCListAppend(MCListRef self, MCValueRef p_value)
8891

8992
bool MCListCopy(MCListRef self, MCListRef& r_list)
9093
{
91-
MCAssert(self != nil);
94+
__MCAssertIsList(self);
9295

9396
// If we are immutable, just bump the reference count
9497
if (!self -> flags & kMCListFlagIsMutable)
@@ -122,6 +125,8 @@ bool MCListCopy(MCListRef self, MCListRef& r_list)
122125

123126
bool MCListCopyAndRelease(MCListRef self, MCListRef& r_list)
124127
{
128+
__MCAssertIsList(self);
129+
125130
// If there are no other references, just clear the mutable flag
126131
if (self -> references == 1)
127132
{
@@ -139,6 +144,8 @@ bool MCListCopyAndRelease(MCListRef self, MCListRef& r_list)
139144

140145
bool MCListCopyAsString(MCListRef self, MCStringRef& r_string)
141146
{
147+
__MCAssertIsList(self);
148+
142149
MCStringRef t_string;
143150
if (self -> buffer != nil)
144151
t_string = self -> buffer;
@@ -163,6 +170,9 @@ bool MCListCopyAsStringAndRelease(MCListRef self, MCStringRef& r_string)
163170

164171
bool MCListAppendFormat(MCListRef self, const char *p_format, ...)
165172
{
173+
__MCAssertIsList(self);
174+
MCAssert(nil != p_format);
175+
166176
bool t_success;
167177
t_success = true;
168178

@@ -185,6 +195,9 @@ bool MCListAppendFormat(MCListRef self, const char *p_format, ...)
185195

186196
bool MCListAppendNativeChars(MCListRef self, const char_t *p_chars, uindex_t p_char_count)
187197
{
198+
__MCAssertIsList(self);
199+
MCAssert(p_chars != nil);
200+
188201
bool t_first = self->buffer == nil;
189202
if (t_first)
190203
if (!MCStringCreateMutable(0, self -> buffer))
@@ -203,6 +216,7 @@ bool MCListAppendSubstring(MCListRef self, MCStringRef p_string, MCRange p_range
203216

204217
bool MCListIsEmpty(MCListRef self)
205218
{
219+
__MCAssertIsList(self);
206220
return self -> buffer == nil;
207221
}
208222

0 commit comments

Comments
 (0)