[U-Boot-Users] how to reuse the malloc function in u-boot?

because our board have a ram on chip, so i need to rewrite a mini loader to run linux, and i want to move the u-boot's malloc function to my mini loader. i find in every board.c it call the mem_malloc_init(); malloc_bin_reloc(); to init someting for malloc. and because my miniloader is linked at ram address, so i think i do not need the malloc_bin_reloc. so i just copy the mem_malloc_init to my miniloader, and modify as { ulong dest_addr = CFG_MALLOC_END;
mem_malloc_end = dest_addr; mem_malloc_start = CFG_MALLOC_START; mem_malloc_brk = mem_malloc_start;
memset ((void *) mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); } and also copy the sbrk to my program.and the dlmalloc,malloc.h are copyed to my program without modification, but it run occur error at the line like set_head(top, top_size | PREV_INUSE); i think it caused by the operation of top. need i do anyting other to run the malloc function correctly?
(BTW: maybe this problem is not in the range of u-boot using, if it make others confused, i apologize)
Thanks for any hints
Best Regards
zhuzhenhua
participants (1)
-
zhuzhenhua