This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Using 2d array where appropriate



This follows JimB's lead.  I committed it.

2000-04-02  Eli Zaretskii  <eliz@is.elta.co.il>

	* go32-nat.c (go32_handle_nonaligned_watchpoint): Use a
	two-dimensional array instead of faking it with index
	arithmetics.

--- gdb/go32-nat.c~1	Fri Mar 10 22:22:56 2000
+++ gdb/go32-nat.c	Sun Apr  2 23:07:12 2000
@@ -859,20 +859,19 @@ go32_handle_nonaligned_watchpoint (wp_op
   int size;
   int rv = 0, status = 0;
 
-  static int size_try_array[16] =
+  static int size_try_array[4][4] =
   {
-    1, 1, 1, 1,			/* trying size one */
-    2, 1, 2, 1,			/* trying size two */
-    2, 1, 2, 1,			/* trying size three */
-    4, 1, 2, 1			/* trying size four */
+    { 1, 1, 1, 1 },		/* trying size one */
+    { 2, 1, 2, 1 },		/* trying size two */
+    { 2, 1, 2, 1 },		/* trying size three */
+    { 4, 1, 2, 1 }		/* trying size four */
   };
 
   while (len > 0)
     {
       align = addr % 4;
-      /* Four is the maximum length for 386.  */
-      size = (len > 4) ? 3 : len - 1;
-      size = size_try_array[size * 4 + align];
+      /* Four is the maximum length a 386 debug register can watch.  */
+      size = size_try_array[len > 4 ? 3 : len - 1][align];
       if (what == wp_insert)
 	status = go32_insert_aligned_watchpoint (waddr, addr, size, rw);
       else if (what == wp_remove)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]