[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Aug 6 03:33:25 CEST 2003


CVS commit by staikos: 

by default, zero memory on resize().  uses memset() for now, but an alternative
method is also provided.


  M +9 -2      kstvector.cpp   1.42
  M +1 -1      kstvector.h   1.34


--- kdeextragear-2/kst/kst/kstvector.cpp  #1.41:1.42
@@ -27,4 +27,7 @@
 #include "kstdoc.h"
 
+// Use 1 for a simple for() loop
+#define ZERO_MEMORY 2
+
 #ifdef NAN
 double KST::NOPOINT = NAN;
@@ -187,13 +190,17 @@ void KstVector::zero() {
 
 
-void KstVector::resize(int sz) {
+void KstVector::resize(int sz, bool reinit) {
   //kdDebug() << "resizing to: " << sz << endl;
   if (sz > 1) {
     _v = static_cast<double*>(realloc(_v, sz*sizeof(double)));
 #ifdef ZERO_MEMORY
-    if (_size < sz) {
+    if (reinit && _size < sz) {
+#if ZERO_MEMORY == 2
+      memset(&_v[_size], 0, (sz - _size)*sizeof(double));
+#else
       for (int i = _size; i < sz; i++) {
         _v[i] = 0.0;
       }
+#endif
     }
 #endif

--- kdeextragear-2/kst/kst/kstvector.h  #1.33:1.34
@@ -101,5 +101,5 @@ public:
   virtual QString fileLabel() const;
 
-  virtual void resize(int sz);
+  virtual void resize(int sz, bool reinit = true);
 
   virtual void SetNewAndShift(int inNew, int inShift);




More information about the Kst mailing list