void* realloc(void *old_mem_ptr,int new_size) { void *ptr = malloc(new_size); if (ptr == NULL) return ptr; memcpy(ptr, old_mem_ptr, new_size); free(old_mem_ptr); return ptr; }template T* realloc_p(T *a,int size)//动态内存追加函数 { T *t ; t = new T[ size ] ; memcpy( t, a , size*sizeof(T) ); delete [] a; return t; } void * realloc( void * OldPtr, size_t NewSize ) { void * NewPtr; if ( !OldPtr) { return malloc( NewSize ); } else if ( NewSize == 0 ) { free( OldPtr ); } else { NewPtr = malloc(NewSize); if ( NewPtr ) { memcpy( NewPtr, OldPtr, NewSize ); free( OldPtr ); return NewPtr; } } return NULL; }