Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualiMalc

Posted 07 April 2013 - 03:45 AM

I haven't looked into your crash problem yet, first a few other observations:

In your Swap method, you made t static. This doesn't really gain you anything, and it takes away the ability to use this in a multi-threaded scenario. I suggest removing the static keyword.

Be careful with the cheap comparison hack of return l - r; It doesn't work in every case, e.g. when r is MIN_INT. The way comparefloat does it is safer.

More commenting isn't always good. Too little is a common problem, but too much can also be a problem. It does depend on the nature of the commenting though. The most important thing to comment is always "Why". Avoid stating the obvious, e.g. "Create two arrays".

This "Array" class seems to be some kind of custom array type with an overloaded [] operator. This is good news as it means that you can add bounds checking to that operator, and hopefully it will find the bug for you. It's almost certainly an out-of-bounds access issue.
Perhaps use asserts for this so that your release build performance isn't affected.

#1iMalc

Posted 07 April 2013 - 03:44 AM

I haven't looked into your crash problem yet, first a few other observations:

In your Swap method, you made t static. This doesn't really gain you anything, and it takes away the ability to use this in a multi-threaded scenario. I suggest removing the static keyword.

Be careful with the cheap comparison hack of return l - r; It doesn't work in every case, e.g. when r is MIN_INT. The way comparefloat does it is safer.

More commenting isn't always good. Too little is a common problem, but too much can also be a problem. It does depend on the nature of the commenting though. The most important thing to comment is always "Why". Aavoid stating the obvious, e.g. "Create two arrays".

This "Array" class seems to be some kind of custom array type with an overloaded [] operator. This is good news as it means that you can add bounds checking to that operator, and hopefully it will find the bug for you. It's almost certainly an out-of-bounds access issue.
Perhaps use asserts for this so that your release build performance isn't affected.

PARTNERS