Commit 122b3ca5 authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

Replace specific DEBUG_MEM in Array implementation by debug assertions.

parent f89446f6
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <cassert>
#include "goo/gmem.h" #include "goo/gmem.h"
#include "Object.h" #include "Object.h"
#include "Array.h" #include "Array.h"
...@@ -105,11 +106,8 @@ void Array::add(Object &&elem) { ...@@ -105,11 +106,8 @@ void Array::add(Object &&elem) {
void Array::remove(int i) { void Array::remove(int i) {
arrayLocker(); arrayLocker();
if (i < 0 || i >= length) { if (i < 0 || i >= length) {
#ifdef DEBUG_MEM assert(i >= 0 && i < length);
abort();
#else
return; return;
#endif
} }
--length; --length;
memmove( static_cast<void*>(elems + i), elems + i + 1, sizeof(elems[0]) * (length - i) ); memmove( static_cast<void*>(elems + i), elems + i + 1, sizeof(elems[0]) * (length - i) );
...@@ -117,22 +115,16 @@ void Array::remove(int i) { ...@@ -117,22 +115,16 @@ void Array::remove(int i) {
Object Array::get(int i, int recursion) const { Object Array::get(int i, int recursion) const {
if (i < 0 || i >= length) { if (i < 0 || i >= length) {
#ifdef DEBUG_MEM assert(i >= 0 && i < length);
abort();
#else
return Object(objNull); return Object(objNull);
#endif
} }
return elems[i].fetch(xref, recursion); return elems[i].fetch(xref, recursion);
} }
Object Array::getNF(int i) const { Object Array::getNF(int i) const {
if (i < 0 || i >= length) { if (i < 0 || i >= length) {
#ifdef DEBUG_MEM assert(i >= 0 && i < length);
abort();
#else
return Object(objNull); return Object(objNull);
#endif
} }
return elems[i].copy(); return elems[i].copy();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment