Revision
23652
Author
dsorresso@apple.com
Date
2008-08-13 11:23:02 -0700 (Wed, 13 Aug 2008)

Log Message

How about we not page in 10 MB every time we send a Mach message ...

Modified Paths

Diff

Modified: branches/PR-5978442/launchd/src/liblaunch.c (23651 => 23652)


--- branches/PR-5978442/launchd/src/liblaunch.c	2008-08-13 01:41:23 UTC (rev 23651)
+++ branches/PR-5978442/launchd/src/liblaunch.c	2008-08-13 18:23:02 UTC (rev 23652)
@@ -641,10 +641,15 @@
 	case LAUNCH_DATA_STRING:
 		o_in_w->string_len = host2wire(d->string_len);
 		total_data_len += ROUND_TO_64BIT_WORD_SIZE(strlen(d->string) + 1);
+		
 		if (total_data_len > len) {
 			return 0;
 		}
 		memcpy(where, d->string, strlen(d->string) + 1);
+		
+		/* Zero padded data. */
+		bzero(o_in_w + (total_data_len - len));
+		
 		break;
 	case LAUNCH_DATA_OPAQUE:
 		o_in_w->opaque_size = host2wire(d->opaque_size);
@@ -653,6 +658,10 @@
 			return 0;
 		}
 		memcpy(where, d->opaque, d->opaque_size);
+		
+		/* Zero padded data. */
+		bzero(o_in_w + (total_data_len - len));
+		
 		break;
 	case LAUNCH_DATA_DICTIONARY:
 	case LAUNCH_DATA_ARRAY:
@@ -779,7 +788,7 @@
 
 		/* hack, see the above assert to verify "correctness" */
 		free(lh->sendbuf);
-		lh->sendbuf = calloc(1, good_enough_size);
+		lh->sendbuf = malloc(good_enough_size);
 		free(lh->sendfds);
 		lh->sendfds = malloc(4 * 1024);