memory bugfixes

This commit is contained in:
2025-06-14 19:43:52 -04:00
parent ef6f7bcb77
commit 99e3e5f48a
38 changed files with 17 additions and 5 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -36,7 +36,7 @@ namespace ams
{
int ret = amsarray_success;
T *newdata = NULL;
amsarray_size_t lmin;
amsarray_size_t lmin = 0;
T defval = T();
if(_newcap<=0)
@@ -48,6 +48,12 @@ namespace ams
return ret;
}
if(_newcap == reserved)
{
ret = amsarray_success;
return ret;
}
newdata = new(std::nothrow) T[_newcap];
if(newdata==NULL)
{
@@ -57,7 +63,7 @@ namespace ams
if(data!=NULL)
{
lmin = (_newcap>=reserved) ? length : _newcap;
lmin = (_newcap>=reserved) ? reserved : _newcap;
ams::buffer_cast_copy<T,T>(newdata,data,lmin);
}
ams::buffer_set<T>(newdata,reserved,_newcap,defval);
@@ -65,7 +71,7 @@ namespace ams
if(data!=NULL) {delete[] data; data = NULL;}
data = newdata;
reserved = _newcap;
length = (length<reserved)? reserved : length;
length = (reserved<length) ? reserved : length;
return ret;
}
@@ -95,7 +101,7 @@ namespace ams
{
int ret = amsarray_success;
int res;
amsarray_size_t q;
amsarray_size_t q = 0;
if(_newlen<=0)
{
@@ -196,8 +202,12 @@ namespace ams
{
if(data!=NULL) {delete[] data; data = NULL;}
length = other.length;
reserved = other.reserved;
growfactor = other.growfactor;
data = other.data;
other.length = 0;
other.reserved = 0;
other.growfactor = 0;
other.data = NULL;
}
return;
@@ -20,12 +20,14 @@ namespace ams
//Is = N/nthread;
Is = (nthread<=0) ? N : N/nthread;
if(Is<=0) Is = 1;
I0 = Is*(threadnum);
I1 = (threadnum>=(nthread-1)) ? N : Is*(threadnum+1);
// I0 = (I0<=0) ? 0 : I0;
// I1 = (I1<=0) ? 0 : I1;
I0 = (I0>N) ? N : I0;
I0 = (I0>(N-1)) ? (N-1) : I0;
I1 = (I1>N) ? N : I1;
for(I=I0;I<I1;I++)