aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flatom.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-03-15 04:56:36 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-03-15 04:56:36 +0000
commit31a2d9dcc2b3a519033918e180f81c4e7b9f8e7e (patch)
tree7eae5d3f1e302843147fdc6bc13c99e101906d32 /externals/grill/flext/source/flatom.cpp
parent3e0446e7fda10c3d85a628b8c1effaa5bf7f5529 (diff)
new data type flext::AtomListStatic using pre-allocated space if possible
fixes for OSX replaced memory-intensive STL maps by custom-made vector/map-container fix for gcc strangeness no more static assignment of symbols (problems with Metrowerks) small fix for gcc fixed bugs in SIMD code for non-power-of-2 lengths fixes for attribute editor (to deal with large dialogs) svn path=/trunk/; revision=2628
Diffstat (limited to 'externals/grill/flext/source/flatom.cpp')
-rw-r--r--externals/grill/flext/source/flatom.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp
index 3562e904..bf057c00 100644
--- a/externals/grill/flext/source/flatom.cpp
+++ b/externals/grill/flext/source/flatom.cpp
@@ -48,33 +48,39 @@ t_atom *flext::CopyList(int argc,const t_atom *argv)
return dst;
}
-flext::AtomList::AtomList(int argc,const t_atom *argv):
- cnt(0),lst(NULL)
+void flext::AtomList::Alloc(int sz)
{
- operator()(argc,argv);
+ if(lst) {
+ if(cnt == sz) return; // no change
+ delete[] lst;
+ }
+ else
+ FLEXT_ASSERT(cnt == 0);
+ lst = new t_atom[cnt = sz];
}
-flext::AtomList::AtomList(const AtomList &a):
- cnt(0),lst(NULL)
+flext::AtomList::~AtomList() { Free(); }
+
+void flext::AtomList::Free()
{
- operator =(a);
+ if(lst) {
+ delete[] lst; lst = NULL;
+ cnt = 0;
+ }
+ else
+ FLEXT_ASSERT(cnt == 0);
}
-flext::AtomList::~AtomList() { Clear(); }
-
-
flext::AtomList &flext::AtomList::Set(int argc,const t_atom *argv,int offs,bool resize)
{
int ncnt = argc+offs;
- if(resize && lst && cnt != ncnt) { delete[] lst; lst = NULL; cnt = 0; }
+ if(resize) Alloc(ncnt);
- if(ncnt) {
- if(!lst) lst = new t_atom[cnt = ncnt];
+ // argv can be NULL indepently from argc
+ if(argv)
+ for(int i = 0; i < argc; ++i)
+ SetAtom(lst[offs+i],argv[i]);
- if(argv) {
- for(int i = 0; i < argc; ++i) SetAtom(lst[offs+i],argv[i]);
- }
- }
return *this;
}
@@ -91,20 +97,16 @@ int flext::AtomList::Compare(const AtomList &a) const
return Count() < a.Count()?-1:1;
}
+flext::AtomListStaticBase::~AtomListStaticBase() { Free(); }
-#if FLEXT_SYS != FLEXT_SYS_JMAX
-// not for jmax as long as t_symbol * == char *
-flext::AtomAnything::AtomAnything(const t_symbol *h,int argc,const t_atom *argv):
- AtomList(argc,argv),hdr(h?h:MakeSymbol(""))
-{}
-#endif
-
-flext::AtomAnything::AtomAnything(const char *h,int argc,const t_atom *argv):
- AtomList(argc,argv),hdr(MakeSymbol(h))
-{}
-
-flext::AtomAnything::AtomAnything(const AtomAnything &a):
- AtomList(a),hdr(a.hdr)
-{}
-
+void flext::AtomListStaticBase::Alloc(int sz)
+{
+ if(sz < precnt) lst = predata,cnt = sz;
+ else AtomList::Alloc(sz);
+}
+void flext::AtomListStaticBase::Free()
+{
+ if(lst != predata) AtomList::Free();
+ else lst = NULL,cnt = 0;
+}