On Fri, 1 Mar 2002, Aaron Bannert wrote:

> Can we put that alignment macro in a common place in APR, since it
> is not useful to apps and internals?

s/not/now/, right?  :)

Does this look right? (attached to avoid line wrapping)

--------------------------------------------------------------
   Cliff Woolley
   [EMAIL PROTECTED]
   Charlottesville, VA

Index: scoreboard.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/scoreboard.c,v
retrieving revision 1.60
diff -u -d -r1.60 scoreboard.c
--- scoreboard.c        27 Feb 2002 04:10:19 -0000      1.60
+++ scoreboard.c        1 Mar 2002 18:59:42 -0000
@@ -132,9 +132,11 @@
 {
     ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
     ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
-    scoreboard_size = sizeof(global_score);
-    scoreboard_size += sizeof(process_score) * server_limit;
-    scoreboard_size += sizeof(worker_score) * server_limit * thread_limit;
+    scoreboard_size  = APR_ALIGN_DEFAULT(sizeof(global_score));
+    scoreboard_size += APR_ALIGN_DEFAULT(sizeof(process_score))
+                            * server_limit;
+    scoreboard_size += APR_ALIGN_DEFAULT(sizeof(worker_score))
+                            * server_limit * thread_limit;
     return scoreboard_size;
 }

@@ -144,18 +146,19 @@
     int i;

     ap_calc_scoreboard_size();
-    ap_scoreboard_image =
-        calloc(1, sizeof(scoreboard) + server_limit * sizeof(worker_score *));
+    ap_scoreboard_image = calloc(1, APR_ALIGN_DEFAULT(sizeof(scoreboard)) +
+                                    server_limit * sizeof(worker_score *));
     more_storage = shared_score;
     ap_scoreboard_image->global = (global_score *)more_storage;
-    more_storage += sizeof(global_score);
+    more_storage += APR_ALIGN_DEFAULT(sizeof(global_score));
     ap_scoreboard_image->parent = (process_score *)more_storage;
-    more_storage += sizeof(process_score) * server_limit;
+    more_storage += APR_ALIGN_DEFAULT(sizeof(process_score)) * server_limit;
     ap_scoreboard_image->servers =
-        (worker_score **)((char*)ap_scoreboard_image + sizeof(scoreboard));
+        (worker_score **)((char*)ap_scoreboard_image +
+                          APR_ALIGN_DEFAULT(sizeof(scoreboard)));
     for (i = 0; i < server_limit; i++) {
         ap_scoreboard_image->servers[i] = (worker_score *)more_storage;
-        more_storage += thread_limit * sizeof(worker_score);
+        more_storage += thread_limit * APR_ALIGN_DEFAULT(sizeof(worker_score));
     }
     ap_assert(more_storage == (char*)shared_score + scoreboard_size);
     ap_scoreboard_image->global->server_limit = server_limit;

Reply via email to