2013-06-29 06:37:03 +04:00
|
|
|
|
2021-02-28 22:57:28 +03:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config_ac.h>
|
|
|
|
#endif
|
|
|
|
|
2013-06-29 06:37:03 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2021-02-27 23:58:05 +03:00
|
|
|
#include <time.h>
|
2013-06-29 06:37:03 +04:00
|
|
|
|
|
|
|
#include "libmem.h"
|
2021-02-28 22:57:28 +03:00
|
|
|
#include "log.h"
|
2013-06-29 06:37:03 +04:00
|
|
|
|
2021-02-27 19:38:03 +03:00
|
|
|
int main(int argc, char **argv)
|
2013-06-29 06:37:03 +04:00
|
|
|
{
|
2021-02-27 19:38:03 +03:00
|
|
|
void *obj;
|
|
|
|
unsigned int addr1;
|
|
|
|
unsigned int addr2;
|
|
|
|
unsigned int addr3;
|
|
|
|
unsigned int addr4;
|
|
|
|
unsigned int addr5;
|
|
|
|
int index;
|
|
|
|
int rd;
|
2021-02-28 22:57:28 +03:00
|
|
|
struct log_config *config;
|
|
|
|
|
|
|
|
config = log_config_init_for_console(LOG_LEVEL_DEBUG, NULL);
|
|
|
|
log_start_from_param(config);
|
|
|
|
log_config_free(config);
|
2023-01-09 15:58:38 +03:00
|
|
|
/* Disable stdout buffering, as this can confuse the error
|
|
|
|
* reporting when running in libcheck fork mode */
|
|
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
2013-06-29 06:37:03 +04:00
|
|
|
|
2021-02-27 19:38:03 +03:00
|
|
|
srand(time(0));
|
|
|
|
obj = libmem_init(0x80000000, 64 * 1024 * 1024);
|
|
|
|
for (index = 0; index < 256; index++)
|
2013-06-29 06:37:03 +04:00
|
|
|
{
|
2021-02-27 19:38:03 +03:00
|
|
|
rd = rand() & 0xffff;
|
|
|
|
printf("1 rd %d\n", rd);
|
|
|
|
addr1 = libmem_alloc(obj, rd);
|
|
|
|
rd = rand() & 0xffff;
|
|
|
|
printf("2 rd %d\n", rd);
|
|
|
|
addr2 = libmem_alloc(obj, rd);
|
|
|
|
rd = rand() & 0xffff;
|
|
|
|
printf("3 rd %d\n", rd);
|
|
|
|
addr3 = libmem_alloc(obj, rd);
|
|
|
|
rd = rand() & 0xffff;
|
|
|
|
printf("4 rd %d\n", rd);
|
|
|
|
addr4 = libmem_alloc(obj, rd);
|
|
|
|
addr5 = libmem_alloc(obj, rd);
|
|
|
|
libmem_free(obj, addr1);
|
|
|
|
printf("5\n");
|
|
|
|
addr1 = libmem_alloc(obj, 64);
|
|
|
|
printf("6\n");
|
|
|
|
libmem_free(obj, addr3);
|
|
|
|
printf("7\n");
|
|
|
|
addr3 = libmem_alloc(obj, 64 * 1024);
|
|
|
|
libmem_free(obj, addr5);
|
|
|
|
addr5 = libmem_alloc(obj, 64 * 1024);
|
|
|
|
printf("8\n");
|
|
|
|
libmem_free(obj, addr1);
|
|
|
|
printf("9\n");
|
|
|
|
libmem_free(obj, addr2);
|
|
|
|
printf("10\n");
|
|
|
|
libmem_free(obj, addr3);
|
|
|
|
libmem_free(obj, addr4);
|
|
|
|
if (index == 255)
|
|
|
|
{
|
|
|
|
libmem_set_flags(obj, 1);
|
|
|
|
}
|
|
|
|
libmem_free(obj, addr5);
|
2013-06-29 06:37:03 +04:00
|
|
|
}
|
2021-02-27 19:38:03 +03:00
|
|
|
libmem_deinit(obj);
|
2021-02-28 22:57:28 +03:00
|
|
|
log_end();
|
2021-02-27 19:38:03 +03:00
|
|
|
return 0;
|
2013-06-29 06:37:03 +04:00
|
|
|
}
|