Пример #1
0
int main() {
    init(sizeof(struct test), 5);

    char c;
    void *x;

    printf("Give command \"y\" to allocate a chunk and \"z <hex addr>\" to free (T*) addr\n\n");

    printFreeBlocks();

    while (1) {
        scanf("%c", &c);
        if (c == 'y') {
            x = alloc();
            if (x != NULL) {
                printf("Allocated address: %p\n\n", x);
                printFreeBlocks();
            } else {
                printf("Allocation failed: No free space\n");
            }
        } else if(c == 'z') {
            unsigned long inp;
            scanf("%lx", &inp);
            free((void *) inp);
            printFreeBlocks();
        }
    }
}
Пример #2
0
int main(void) {

	initHeap();
	initHeap();
	printBlock((struct MemBlock*)memPool);
	printf("Adresse: %p \n", memPool);
	printf("Absolute Adresse: %p \n",rel_to_Abs(7));
	printf("Relative Adresse: %d \n",abs_to_Rel(0x404107));
	printFreeBlocks();
	return EXIT_SUCCESS;
}
Пример #3
0
/*############################################################################*/
int main() {
    initHeap();
    printFreeBlocks();
    return 0;
}