git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5792 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2011-03-16 15:21:59 +00:00
parent c4c79006a1
commit 8dad49156d
21 changed files with 818 additions and 602 deletions

View File

@ -71,6 +71,51 @@ void *Memory::srealloc(void *ptr, int n, const char *name)
return ptr;
}
/* ----------------------------------------------------------------------
newer routines
------------------------------------------------------------------------- */
void *Memory::smalloc_new(bigint nbytes, const char *name)
{
if (nbytes == 0) return NULL;
void *ptr = malloc(nbytes);
if (ptr == NULL) {
char str[128];
sprintf(str,"Failed to allocate " BIGINT_FORMAT "bytes for array %s",
nbytes,name);
error->one(str);
}
return ptr;
}
void *Memory::srealloc_new(void *ptr, bigint nbytes, const char *name)
{
if (nbytes == 0) {
sfree_new(ptr);
return NULL;
}
ptr = realloc(ptr,nbytes);
if (ptr == NULL) {
char str[128];
sprintf(str,"Failed to reallocate " BIGINT_FORMAT "bytes for array %s",
nbytes,name);
error->one(str);
}
return ptr;
}
void Memory::sfree_new(void *ptr)
{
if (ptr == NULL) return;
free(ptr);
}
/* ----------------------------------------------------------------------
older routines
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
create a 1d double array with index from nlo to nhi inclusive
------------------------------------------------------------------------- */
@ -361,7 +406,6 @@ void Memory::destroy_3d_double_array(double ***array, int n1_offset,
sfree(array + n1_offset);
}
/* ----------------------------------------------------------------------
create a 3d int array
------------------------------------------------------------------------- */