-
-
Save lxylxy123456/1cb7c1319aaf37373c6712e7cfae35ad to your computer and use it in GitHub Desktop.
https://github.com/OSPreservProject/oskit/issues/1 supplementary program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Steps to build lmm and compile this file: | |
# Clone https://github.com/OSPreservProject/oskit to current directory | |
./configure | |
cd lmm; make; cd .. | |
# Put this file to "a.c" | |
cc -I . a.c -o a lmm/liboskit_lmm.a | |
./a | |
*/ | |
#include <assert.h> | |
#include <stdio.h> | |
#include "oskit/lmm.h" | |
lmm_t lmm = LMM_INITIALIZER; | |
lmm_region_t lmm_region; | |
char mem[4096]; | |
void panic(const char *fmt, ...) { | |
assert(0); | |
} | |
int main() { | |
printf("mem = %p\n", mem); | |
printf("lmm_init\n"); | |
lmm_init(&lmm); | |
printf("lmm_add_region\n"); | |
lmm_add_region(&lmm, &lmm_region, mem, 4096, 0, 0); | |
printf("lmm_add_free(&lmm, mem + 8, 4096 - 8)\n"); | |
lmm_add_free(&lmm, mem + 8, 4096 - 8); | |
if (1) { | |
printf("lmm_add_free(&lmm, mem + 1, 3)\n"); | |
lmm_add_free(&lmm, mem + 1, 3); | |
} | |
printf("lmm_alloc\n"); | |
printf("result: %p\n", lmm_alloc(&lmm, 15, 0)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment