ObjFW  Diff

Differences From Artifact [8d78186ef9]:

To Artifact [b4196ed858]:


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#include <assert.h>

#import "ObjFW_RT.h"
#import "private.h"

static struct objc_hashtable *classes = NULL;
static unsigned classes_cnt = 0;
static Class *load_queue = NULL;
static size_t load_queue_cnt = 0;







<
<







18
19
20
21
22
23
24


25
26
27
28
29
30
31
#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>



#import "ObjFW_RT.h"
#import "private.h"

static struct objc_hashtable *classes = NULL;
static unsigned classes_cnt = 0;
static Class *load_queue = NULL;
static size_t load_queue_cnt = 0;
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594

	objc_global_mutex_lock();

	if ((ret = malloc((classes_cnt + 1) * sizeof(Class))) == NULL)
		OBJC_ERROR("Failed to allocate memory for class list!");

	count = objc_getClassList(ret, classes_cnt);
	assert(count == classes_cnt);

	ret[count] = Nil;

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

	objc_global_mutex_unlock();







|







578
579
580
581
582
583
584
585
586
587
588
589
590
591
592

	objc_global_mutex_lock();

	if ((ret = malloc((classes_cnt + 1) * sizeof(Class))) == NULL)
		OBJC_ERROR("Failed to allocate memory for class list!");

	count = objc_getClassList(ret, classes_cnt);
	OF_ENSURE(count == classes_cnt);

	ret[count] = Nil;

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

	objc_global_mutex_unlock();
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
			 * UINT32_MAX so that it will get increased at the end
			 * of the loop and thus become 0.
			 */
			i = UINT32_MAX;
		}
	}

	assert(classes_cnt == 0);

	if (empty_dtable != NULL) {
		objc_dtable_free(empty_dtable);
		empty_dtable = NULL;
	}

	objc_sparsearray_free(fast_path);
	fast_path = NULL;

	objc_hashtable_free(classes);
	classes = NULL;
}







|












914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
			 * UINT32_MAX so that it will get increased at the end
			 * of the loop and thus become 0.
			 */
			i = UINT32_MAX;
		}
	}

	OF_ENSURE(classes_cnt == 0);

	if (empty_dtable != NULL) {
		objc_dtable_free(empty_dtable);
		empty_dtable = NULL;
	}

	objc_sparsearray_free(fast_path);
	fast_path = NULL;

	objc_hashtable_free(classes);
	classes = NULL;
}