Loading...
libkern/c++/OSRuntime.cpp xnu-344.49 xnu-792.6.56
--- xnu/xnu-344.49/libkern/c++/OSRuntime.cpp
+++ xnu/xnu-792.6.56/libkern/c++/OSRuntime.cpp
@@ -2,8 +2,6 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
@@ -70,7 +68,7 @@
 #endif
 
 	mem->mlen = memsize;
-	(void) memset(mem->dat, 0, size);
+	bzero( mem->dat, size);
 
 	return  (mem->dat);
 }
@@ -92,7 +90,7 @@
 #if 0
 	memset((vm_offset_t)hdr, 0xbb, hdr->mlen);
 #else
-	kfree((vm_offset_t)hdr, hdr->mlen);
+	kfree(hdr, hdr->mlen);
 #endif
 }
 
@@ -133,7 +131,7 @@
 		(void) memset(&nmem->dat[osize], 0, nsize - osize);
 	(void) memcpy(nmem->dat, ohdr->dat,
 					(nsize > osize) ? osize : nsize);
-	kfree((vm_offset_t)ohdr, ohdr->mlen);
+	kfree(ohdr, ohdr->mlen);
 
 	return (nmem->dat);
 }
@@ -158,7 +156,11 @@
 
 typedef void (*structor_t)(void);
 
-void OSRuntimeUnloadCPPForSegment(struct segment_command * segment) {
+// Given a pointer to a 32 bit mach object segment, iterate the segment to
+// obtain a 32 bit destructor section for C++ objects, and call each of the
+// destructors there.
+void
+OSRuntimeUnloadCPPForSegment(struct segment_command * segment) {
 
     struct section * section;
 
@@ -182,6 +184,7 @@
     return;
 }
 
+// This function will only operate on 32 bit kmods
 void OSRuntimeUnloadCPP(kmod_info_t *ki, void *)
 {
     if (ki && ki->address) {
@@ -224,6 +227,7 @@
 }
 
 // Functions used by the extenTools/kmod library project
+// This function will only operate on 32 bit kmods
 kern_return_t OSRuntimeInitializeCPP(kmod_info_t *ki, void *)
 {
     struct mach_header *header;
@@ -331,8 +335,6 @@
     void * result;
 
     result = (void *) kern_os_malloc( size);
-    if( result)
-	bzero( result, size);
     return( result);
 }