summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-12-08 09:54:15 -0700
committerBrian Paul <brianp@vmware.com>2009-12-08 10:03:43 -0700
commit7fb5daa7870d559b431d9f6eba2f6c3d74dafbbe (patch)
tree643b39151084b4e4d2003590e99adde444a9b2fd
parenta12956a5069b345ca1228f1c058c8922b8b66339 (diff)
dsconfig: zero-out all fields in the string parser constructor
Otherwise, if a field wasn't read from the file, the field had a random value.
-rw-r--r--src/libs/dsurf/dsconfig.cpp57
-rw-r--r--src/libs/dsurf/dsconfig.h2
2 files changed, 59 insertions, 0 deletions
diff --git a/src/libs/dsurf/dsconfig.cpp b/src/libs/dsurf/dsconfig.cpp
index cf2f769..2b64de1 100644
--- a/src/libs/dsurf/dsconfig.cpp
+++ b/src/libs/dsurf/dsconfig.cpp
@@ -179,6 +179,61 @@ template<class T> inline T abs(T a) {return (a < 0)? -a: a;}
namespace GLEAN {
+// init all config fields to zero
+void
+DrawingSurfaceConfig::zeroFields()
+{
+#if defined(__X11__)
+ visID = 0;
+# if defined(GLX_VERSION_1_3)
+ fbcID = 0;
+# endif
+#elif defined(__WIN__)
+ pfdID = 0;
+#elif defined(__AGL__)
+ pfID = 0;
+#else
+# error "what's the config ID?"
+#endif
+ canRGBA = 0;
+ canCI = 0;
+ bufSize = 0;
+ level = 0;
+ db = 0;
+ stereo = 0;
+ aux = 0;
+ r = 0;
+ g = 0;
+ b = 0;
+ a = 0;
+ z = 0;
+ s = 0;
+ accR = 0;
+ accG = 0;
+ accB = 0;
+ accA = 0;
+ samples = 0;
+ canWindow = 0;
+#if defined(__X11__)
+ canPixmap = 0;
+#if defined(GLX_VERSION_1_3)
+ canPBuffer = 0;
+ maxPBufferWidth = 0;
+ maxPBufferHeight = 0;
+ maxPBufferPixels = 0;
+#endif
+#endif
+ canWinSysRender = 0;
+ fast = 0;
+ conformant = 0;
+ transparent = 0;
+ transR = 0;
+ transG = 0;
+ transB = 0;
+ transA = 0;
+ transI = 0;
+}
+
#if defined(__X11__)
@@ -486,6 +541,8 @@ DrawingSurfaceConfig::DrawingSurfaceConfig(string& str) {
if (!mapsInitialized)
initializeMaps();
+ zeroFields();
+
try {
Lex lex(str.c_str());
diff --git a/src/libs/dsurf/dsconfig.h b/src/libs/dsurf/dsconfig.h
index ea7ffd7..3a9ff8b 100644
--- a/src/libs/dsurf/dsconfig.h
+++ b/src/libs/dsurf/dsconfig.h
@@ -186,6 +186,8 @@ class DrawingSurfaceConfig {
// Utilities:
+ void zeroFields();
+
string canonicalDescription();
// Return a string containing all the attributes in a
// drawing surface configuration. This allows the config