[PD-cvs] externals/grill/flext/source flatom.cpp,1.15,1.16
Thomas Grill
xovo at users.sourceforge.net
Tue Mar 14 18:13:47 CET 2006
Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12604/source
Modified Files:
flatom.cpp
Log Message:
fixed faulty assertion
fixed buggy memory deallocation for AtomListStatic
Index: flatom.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flatom.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** flatom.cpp 12 Dec 2005 00:18:21 -0000 1.15
--- flatom.cpp 14 Mar 2006 17:13:44 -0000 1.16
***************
*** 62,78 ****
{
if(lst) {
! if(cnt == sz) return; // no change
t_atom *l;
if(sz) {
l = new t_atom[sz];
! if(keepix >= 0)
// keep contents
! CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix);
}
else
l = NULL;
! delete[] lst;
lst = l,cnt = sz;
}
--- 62,91 ----
{
if(lst) {
! if(cnt == sz) {
! if(keepix != keepto) {
! int c = keeplen >= 0?keeplen:cnt;
! FLEXT_ASSERT(c+keepto <= cnt);
! FLEXT_ASSERT(c+keepix <= cnt);
! CopyAtoms(c,lst+keepto,lst+keepix);
! }
!
! return; // no change
! }
t_atom *l;
if(sz) {
l = new t_atom[sz];
! if(keepix >= 0) {
// keep contents
! int c = keeplen >= 0?keeplen:(cnt > sz?sz:cnt);
! FLEXT_ASSERT(c+keepto <= sz);
! FLEXT_ASSERT(c+keepix <= cnt);
! CopyAtoms(c,l+keepto,lst+keepix);
! }
}
else
l = NULL;
! Free();
lst = l,cnt = sz;
}
***************
*** 123,131 ****
void flext::AtomListStaticBase::Alloc(int sz,int keepix,int keeplen,int keepto)
{
! if(sz < precnt) {
if(lst != predata && lst) {
! if(keepix >= 0)
// keep contents
! CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix);
AtomList::Free();
}
--- 136,154 ----
void flext::AtomListStaticBase::Alloc(int sz,int keepix,int keeplen,int keepto)
{
! if(sz <= precnt) {
! // small enough for pre-allocated space
!
if(lst != predata && lst) {
! // currently allocated memory is larger than what we need
!
! if(keepix >= 0) {
// keep contents
! int c = keeplen >= 0?keeplen:(cnt > sz?sz:cnt);
! FLEXT_ASSERT(c+keepto <= precnt);
! FLEXT_ASSERT(c+keepix <= cnt);
! CopyAtoms(c,predata+keepto,lst+keepix);
! }
!
! // free allocated memory
AtomList::Free();
}
More information about the Pd-cvs
mailing list