summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAriel Manzur <ariel@okamstudio.com>2016-02-19 05:40:24 -0300
committerAriel Manzur <ariel@okamstudio.com>2016-02-19 05:40:24 -0300
commit0846ab6a5f42845686280167529028dbaf1b37df (patch)
tree58e7e4424a6b031a92e812c42e61c2874b926b09 /core
parentc0e7155591184dffe2d292a0b17d19cb852ae6b2 (diff)
fixes array allocation bug and sets DEFAULT_ALIGNMENT to 1. probably needs testing
Diffstat (limited to 'core')
-rw-r--r--core/os/memory.h8
-rw-r--r--core/typedefs.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/core/os/memory.h b/core/os/memory.h
index 98b973bc06..3fe845aff4 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -308,11 +308,11 @@ T* memnew_arr_template(size_t p_elements,const char *p_descr="") {
same strategy used by std::vector, and the DVector class, so it should be safe.*/
size_t len = sizeof(T) * p_elements;
- unsigned int *mem = (unsigned int*)Memory::alloc_static( len + DEFAULT_ALIGNMENT, p_descr );
+ unsigned int *mem = (unsigned int*)Memory::alloc_static( len + sizeof(size_t), p_descr );
T *failptr=0; //get rid of a warning
ERR_FAIL_COND_V( !mem, failptr );
*mem=p_elements;
- mem = (unsigned int *)( ((uint8_t*)mem) + DEFAULT_ALIGNMENT);
+ mem = (unsigned int *)( ((uint8_t*)mem) + sizeof(size_t));
T* elems = (T*)mem;
/* call operator new */
@@ -331,14 +331,14 @@ T* memnew_arr_template(size_t p_elements,const char *p_descr="") {
template<typename T>
size_t memarr_len(const T *p_class) {
- uint8_t* ptr = ((uint8_t*)p_class) - DEFAULT_ALIGNMENT;
+ uint8_t* ptr = ((uint8_t*)p_class) - sizeof(size_t);
return *(size_t*)ptr;
}
template<typename T>
void memdelete_arr(T *p_class) {
- unsigned int * elems = (unsigned int*)(((uint8_t*)p_class) - DEFAULT_ALIGNMENT);
+ unsigned int * elems = (unsigned int*)(((uint8_t*)p_class) - sizeof(size_t));
for (unsigned int i=0;i<*elems;i++) {
diff --git a/core/typedefs.h b/core/typedefs.h
index 1ca7a4f66d..700346c3bd 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -74,7 +74,7 @@
#endif
#ifndef DEFAULT_ALIGNMENT
-#define DEFAULT_ALIGNMENT 16
+#define DEFAULT_ALIGNMENT 1
#endif