项目作者: eloj

项目描述 :
Memory allocation/pointer elimination experiments
高级语言: C
项目地址: git://github.com/eloj/pma.git
创建时间: 2017-07-20T21:58:39Z
项目社区:https://github.com/eloj/pma

开源协议:

下载


Overview

This repo contains some code for my Memory allocation/pointer elimination experiments.

I would not advice using this code for anything serious.

Example run

  1. $ make && ./pma_test 4
  2. arg1 alignment=4 (16 bytes)
  3. HW page size=4096
  4. Allocated new 4096 byte page @ 0x21cb020
  5. First page at 0x21cb020
  6. Page header is 16 bytes, 4080 bytes available (4 bytes slack). Max allocation size is 4080 bytes.
  7. 0 @[000000] = 'Hello'
  8. 1 @[000001] = 'World'
  9. 2 @[000002] = '!'
  10. Aligned to 4, '<a string at the end of the page>' takes 48 bytes (14 bytes slack).
  11. Allocated new 4096 byte page @ 0x21cc030
  12. >>>@[000252] = '<a string at the end of the page>' == '<a string at the end of the page>'
  13. Writing page @ 0x21cb020 to test-p0000.bin (4096 bytes)
  14. Writing page @ 0x21cc030 to test-p0001.bin (4096 bytes)
  15. Freeing 4096 page (4096 used/0 free) @ 0x21cb020 (.next=0x21cc030)
  16. Freeing 4096 page (4096 used/0 free) @ 0x21cc030 (.next=(nil))
  17. $ hexdump -C test-p0000.bin
  18. 00000000 c0 86 97 00 00 00 00 00 00 10 00 00 00 00 00 00 |................|
  19. 00000010 48 65 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 |Hello...........|
  20. 00000020 57 6f 72 6c 64 00 00 00 00 00 00 00 00 00 00 00 |World...........|
  21. 00000030 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |!...............|
  22. 00000040 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 |0123456789abcdef|
  23. *
  24. 00001000
  25. $ hexdump -C test-p0001.bin
  26. 00000000 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 |................|
  27. 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  28. *
  29. 00000fd0 3c 61 20 73 74 72 69 6e 67 20 61 74 20 74 68 65 |<a string at the|
  30. 00000fe0 20 65 6e 64 20 6f 66 20 74 68 65 20 70 61 67 65 | end of the page|
  31. 00000ff0 3e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |>...............|
  32. 00001000