talloc.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. discard """
  2. disabled: "appveyor"
  3. """
  4. # appveyor is "out of memory"
  5. var x: ptr int
  6. x = cast[ptr int](alloc(7))
  7. doAssert x != nil
  8. x = cast[ptr int](x.realloc(2))
  9. doAssert x != nil
  10. x.dealloc()
  11. x = createU(int, 3)
  12. doAssert x != nil
  13. x.dealloc()
  14. x = create(int, 4)
  15. doAssert cast[ptr array[4, int]](x)[0] == 0
  16. doAssert cast[ptr array[4, int]](x)[1] == 0
  17. doAssert cast[ptr array[4, int]](x)[2] == 0
  18. doAssert cast[ptr array[4, int]](x)[3] == 0
  19. x = x.resize(4)
  20. doAssert x != nil
  21. x.dealloc()
  22. x = cast[ptr int](allocShared(100))
  23. doAssert x != nil
  24. deallocShared(x)
  25. x = createSharedU(int, 3)
  26. doAssert x != nil
  27. x.deallocShared()
  28. x = createShared(int, 3)
  29. doAssert x != nil
  30. doAssert cast[ptr array[3, int]](x)[0] == 0
  31. doAssert cast[ptr array[3, int]](x)[1] == 0
  32. doAssert cast[ptr array[3, int]](x)[2] == 0
  33. doAssert x != nil
  34. x = cast[ptr int](x.resizeShared(2))
  35. doAssert x != nil
  36. x.deallocShared()
  37. x = create(int, 10)
  38. doAssert x != nil
  39. x = x.resize(12)
  40. doAssert x != nil
  41. x.dealloc()
  42. x = createShared(int, 1)
  43. doAssert x != nil
  44. x = x.resizeShared(1)
  45. doAssert x != nil
  46. x.deallocShared()
  47. x = cast[ptr int](alloc0(125 shl 23))
  48. dealloc(x)
  49. x = cast[ptr int](alloc0(126 shl 23))
  50. dealloc(x)