talloc.nim 1.1 KB

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