aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flsupport.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-30 04:32:19 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-30 04:32:19 +0000
commit62530f3fc55d3dc1c12bcd3b88f0922c15cd82e5 (patch)
treea57fc5a54ed78f189f074724396f81330faf9a3b /externals/grill/flext/source/flsupport.cpp
parent562dcc336797951b2a8707413aa44177484c9f2a (diff)
""
svn path=/trunk/; revision=310
Diffstat (limited to 'externals/grill/flext/source/flsupport.cpp')
-rw-r--r--externals/grill/flext/source/flsupport.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index cd57dfd8..827896e3 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -48,6 +48,48 @@ void flext::Setup()
#endif
}
+
+/////////////////////////////////////////////////////////
+// overloaded new/delete memory allocation methods
+//
+/////////////////////////////////////////////////////////
+
+void *flext::operator new(size_t bytes)
+{
+ bytes += sizeof(size_t);
+ char *blk = (char *)getbytes(bytes);
+ *(size_t *)blk = bytes;
+ return blk+sizeof(size_t);
+}
+
+void flext::operator delete(void *blk)
+{
+ char *ori = (char *)blk-sizeof(size_t);
+ size_t bytes = *(size_t *)ori;
+ freebytes(ori,bytes);
+}
+
+void *flext::NewAligned(size_t bytes,int bitalign)
+{
+ const size_t ovh = sizeof(size_t)+sizeof(char *);
+ const unsigned long alignovh = bitalign/8-1;
+ bytes += ovh+alignovh;
+ char *blk = (char *)getbytes(bytes);
+ char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh);
+ *(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk;
+ *(size_t *)(ablk-sizeof(size_t)) = bytes;
+ return ablk;
+}
+
+void flext::FreeAligned(void *blk)
+{
+ char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *));
+ size_t bytes = *(size_t *)((char *)blk-sizeof(size_t));
+ freebytes(ori,bytes);
+}
+
+// ------------------------------------------
+
void flext::GetAString(const t_atom &a,char *buf,int szbuf)
{
#if FLEXT_SYS == FLEXT_SYS_PD