Skip to main content
fixed per @RezoMegrelidze's reference
Source Link
Snowbody
  • 8.7k
  • 25
  • 50
  • UIntPtr is the wrong type to represent a count (it's basically a void *). You want UInt32 or UInt64 depending on your architecture.UIntPtr is the wrong type to represent a count (it's basically a void *). You want UInt32 or UInt64 depending on your architecture.
  • Count should be private set; callers should not be able to change it directly
  • Why are elemsize and alloclength both signed ints? Shouldn't they be unsigned? Or at least check the incoming elemsize in the constructor?
  • I hope that the documentation explains that the FreeFunction is for freeing individual elements that the Stack owns if it gets destroyed nonempty.
  • What's supposed to happen when they Pop an empty stack? Right now you get undefined behavior.
  • What's supposed to happen if the malloc() or realloc() fails?
  • UIntPtr is the wrong type to represent a count (it's basically a void *). You want UInt32 or UInt64 depending on your architecture.
  • Count should be private set; callers should not be able to change it directly
  • Why are elemsize and alloclength both signed ints? Shouldn't they be unsigned? Or at least check the incoming elemsize in the constructor?
  • I hope that the documentation explains that the FreeFunction is for freeing individual elements that the Stack owns if it gets destroyed nonempty.
  • What's supposed to happen when they Pop an empty stack? Right now you get undefined behavior.
  • What's supposed to happen if the malloc() or realloc() fails?
  • UIntPtr is the wrong type to represent a count (it's basically a void *). You want UInt32 or UInt64 depending on your architecture.
  • Count should be private set; callers should not be able to change it directly
  • Why are elemsize and alloclength both signed ints? Shouldn't they be unsigned? Or at least check the incoming elemsize in the constructor?
  • I hope that the documentation explains that the FreeFunction is for freeing individual elements that the Stack owns if it gets destroyed nonempty.
  • What's supposed to happen when they Pop an empty stack? Right now you get undefined behavior.
  • What's supposed to happen if the malloc() or realloc() fails?
Source Link
Snowbody
  • 8.7k
  • 25
  • 50

  • UIntPtr is the wrong type to represent a count (it's basically a void *). You want UInt32 or UInt64 depending on your architecture.
  • Count should be private set; callers should not be able to change it directly
  • Why are elemsize and alloclength both signed ints? Shouldn't they be unsigned? Or at least check the incoming elemsize in the constructor?
  • I hope that the documentation explains that the FreeFunction is for freeing individual elements that the Stack owns if it gets destroyed nonempty.
  • What's supposed to happen when they Pop an empty stack? Right now you get undefined behavior.
  • What's supposed to happen if the malloc() or realloc() fails?