Added
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 2 Mar 2002 05:44:18 +0000 (05:44 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 2 Mar 2002 05:44:18 +0000 (05:44 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1969 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/regression/tests/bug-524691.c [new file with mode: 0644]

diff --git a/support/regression/tests/bug-524691.c b/support/regression/tests/bug-524691.c
new file mode 100644 (file)
index 0000000..542cedc
--- /dev/null
@@ -0,0 +1,39 @@
+/* Division by powers of two.
+ */
+#include <testfwk.h>
+
+typedef unsigned int UINT;
+
+typedef struct _HeapEntryState
+{
+  void *pBase;
+  UINT uFlags;
+} HeapEntryState;
+
+static HeapEntryState *_getHeapEntryState(void *p, HeapEntryState *pStates, UINT nStateEntries)
+{
+  int uLeft = -1, uRight = nStateEntries, uMiddle;
+
+  while (uRight - uLeft > 1)
+    {
+      int iDiff;
+
+      uMiddle = (uLeft + uRight)/2;
+      iDiff = pStates[uMiddle].pBase - p;
+
+      if (iDiff > 0)
+       {
+         uRight = uMiddle;
+       }
+      else if (iDiff < 0)
+       {
+         uLeft = uMiddle;
+       }
+      else
+       {
+         return pStates + uMiddle;
+       }
+    }
+
+  return NULL;
+}