ObjFW  Diff

Differences From Artifact [d2a643d575]:

To Artifact [b1aba62100]:


22
23
24
25
26
27
28
29
30
31



32
33
34
35
36
37
38


39

40
41



42
43
44
45
46
47


48
49
50
51
52
53
54
55
56
22
23
24
25
26
27
28



29
30
31

32


33
34
35
36
37

38
39
40
41
42
43
44
45
46
47


48
49


50
51
52
53
54
55
56







-
-
-
+
+
+
-

-
-



+
+
-
+


+
+
+




-
-
+
+
-
-








Ivar *
class_copyIvarList(Class class, unsigned int *outCount)
{
	unsigned int count;
	Ivar *ivars;

	if (class == Nil)
		return NULL;

	if (class == Nil) {
		if (outCount != NULL)
			*outCount = 0;
	objc_global_mutex_lock();

	if (class->ivars == NULL) {
		objc_global_mutex_unlock();
		return NULL;
	}

	objc_global_mutex_lock();

	count = class->ivars->count;
	count = (class->ivars != NULL ? class->ivars->count : 0);

	if (count == 0) {
		if (outCount != NULL)
			*outCount = 0;

		objc_global_mutex_unlock();
		return NULL;
	}

	if ((ivars = malloc((count + 1) * sizeof(Ivar))) == NULL) {
		objc_global_mutex_unlock();
	if ((ivars = malloc((count + 1) * sizeof(Ivar))) == NULL)
		OBJC_ERROR("Not enough memory to copy ivars");
		return NULL;
	}

	for (unsigned int i = 0; i < count; i++)
		ivars[i] = &class->ivars->ivars[i];
	ivars[count] = NULL;

	if (outCount != NULL)
		*outCount = count;