#ifndef tools_realloc #define tools_realloc #include "typedefs" #include //memcpy namespace tools { template inline bool realloc(T*& a_pointer,uint32 a_new_size,uint32 a_old_size,bool a_init = false) { if(!a_new_size) { delete [] a_pointer; a_pointer = 0; return true; } if(!a_pointer) { a_pointer = new T[a_new_size]; return true; } if(a_old_size==a_new_size) return true; T* pointer = new T[a_new_size]; if(!pointer) { delete [] a_pointer; a_pointer = 0; return false; } if(a_new_size>a_old_size) { ::memcpy(pointer,a_pointer,a_old_size*sizeof(T)); if(a_init){ uint32 num = a_new_size-a_old_size; T* pos = pointer+a_old_size; for(uint32 i=0;i