46 lines
774 B
C
46 lines
774 B
C
#include <assert.h>
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <kolibrios/syscall.h>
|
|
|
|
#define MAX_ALLOCS 10000
|
|
|
|
int
|
|
main ()
|
|
{
|
|
void *allocs[MAX_ALLOCS] = { 0 };
|
|
|
|
// Check zero param
|
|
void *ptr = malloc (0);
|
|
free (ptr);
|
|
free (NULL);
|
|
|
|
// malloc() and free()
|
|
for (size_t i = 0; i < 1000; i++)
|
|
{
|
|
void *ptr = malloc (9999);
|
|
assert (ptr != NULL);
|
|
memset (ptr, 0xFF, 9999);
|
|
free (ptr);
|
|
}
|
|
|
|
// malloc()
|
|
for (size_t i = 0; i < MAX_ALLOCS; i++)
|
|
{
|
|
allocs[i] = malloc (9999);
|
|
assert (allocs[i] != NULL);
|
|
memset (allocs[i], 0xFF, 9999);
|
|
}
|
|
|
|
// free()
|
|
for (size_t i = 0; i < MAX_ALLOCS; i++)
|
|
{
|
|
free (allocs[i]);
|
|
}
|
|
|
|
_ksys_dbg_print ("I: Malloc test: OK");
|
|
return 0;
|
|
}
|