harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r574362 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Date Mon, 10 Sep 2007 20:30:08 GMT
Author: hindessm
Date: Mon Sep 10 13:30:07 2007
New Revision: 574362

URL: http://svn.apache.org/viewvc?rev=574362&view=rev
Log:
Use hymem_{allocate,free}_memory functions instead of malloc/free.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=574362&r1=574361&r2=574362&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Mon Sep 10 13:30:07 2007
@@ -57,6 +57,7 @@
 
 JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
   (JNIEnv * env, jobject clz, jobject address, jobject localaddr,  jint ttl, jint timeout){
+  PORT_ACCESS_FROM_ENV (env);
   struct sockaddr_in dest,source,local;
   struct icmp * send_buf = 0;
   struct ip * recv_buf = 0;
@@ -93,12 +94,12 @@
     bind(sock, (struct sockaddr *)& local, sizeof(local));
   }
 
-  send_buf = (struct icmp*)malloc(sizeof(char)*ICMP_SIZE);
+  send_buf = (struct icmp*)hymem_allocate_memory(sizeof(char)*ICMP_SIZE);
   if (NULL == send_buf) {
     ret = NOPRIVILEGE;
     goto cleanup;
   }
-  recv_buf = (struct ip*)malloc(sizeof(char)*PACKET_SIZE);
+  recv_buf = (struct ip*)hymem_allocate_memory(sizeof(char)*PACKET_SIZE);
   if (NULL == recv_buf) {
     ret = NOPRIVILEGE;
     goto cleanup;
@@ -142,11 +143,11 @@
 cleanup:
 
   if (send_buf != NULL) {
-      free(send_buf);
+      hymem_free_memory(send_buf);
   }
 
   if (recv_buf != NULL) {
-      free(recv_buf);
+      hymem_free_memory(recv_buf);
   }
 
   return ret;
@@ -259,6 +260,7 @@
 
 JNIEXPORT jobject JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannelImpl
   (JNIEnv * env , jobject clz){
+    PORT_ACCESS_FROM_ENV (env);
     int socket = 0;
     int opt;
     int length = sizeof(opt);
@@ -289,7 +291,7 @@
 		if(AF_INET != local_addr.sin_family || length != sizeof(struct sockaddr)){
 			return NULL;
 		}
-		localAddr = malloc(sizeof(jbyte)*4);
+		localAddr = hymem_allocate_memory(sizeof(jbyte)*4);
 		if (NULL == localAddr){
 			return NULL;
 		}
@@ -298,7 +300,7 @@
 	if(0 != getpeername(socket,(struct sockaddr *)&remote_addr,(unsigned int *)&length))
{
 		remote_addr.sin_port = 0;
                 remote_addr.sin_addr.s_addr = 0;
-		address = malloc(sizeof(jbyte)*4);
+		address = hymem_allocate_memory(sizeof(jbyte)*4);
                 if (NULL == address) {
                   goto clean;
                 }
@@ -307,13 +309,13 @@
 		if(AF_INET != remote_addr.sin_family || length != sizeof(struct sockaddr))	{
 			return NULL;
 		}
-		address = malloc(sizeof(jbyte)*4);
+		address = hymem_allocate_memory(sizeof(jbyte)*4);
                 if (NULL == address) {
                   goto clean;
                 }
 		memcpy (address, &(remote_addr.sin_addr.s_addr), 4);
 	}
-	sock = malloc(sizeof(hysocket_struct));
+	sock = hymem_allocate_memory(sizeof(hysocket_struct));
         /* TODO: where is sock free'd? */
         if (NULL == sock) {
           goto clean;
@@ -328,12 +330,12 @@
 		//socket
 		channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/SocketChannelImpl");
         	if(NULL == channel_class) {
-                    free(sock);
+                    hymem_free_memory(sock);
         	    goto clean;
 	        }
 		channel_object = getJavaNioChannelsSocketChannelImplObj(env,channel_class);
           	if(NULL == channel_object) {
-                    free(sock);
+                    hymem_free_memory(sock);
 	            goto clean;
         	}
 		// new and set FileDescript
@@ -357,7 +359,7 @@
 		}
 	  } else {
                 // sock isn't used on this code path so we should free it
-                free(sock);
+                hymem_free_memory(sock);
 		//serverSocket	
 		channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/ServerSocketChannelImpl");
         	if(NULL == channel_class) {
@@ -396,12 +398,12 @@
 	  // new DatagramChannel
 	  channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/DatagramChannelImpl");
           if(NULL == channel_class) {
-              free(sock);
+              hymem_free_memory(sock);
               goto clean;
           }
           channel_object = getJavaNioChannelsSocketChannelImplObj(env,channel_class);
           if(NULL == channel_object) {
-              free(sock);
+              hymem_free_memory(sock);
               goto clean;
           }
 	  // new and set FileDescript
@@ -416,7 +418,7 @@
 	  }
         }	
  clean:
-	free(address);
-	free(localAddr);
+	hymem_free_memory(address);
+	hymem_free_memory(localAddr);
 	return channel_object;
 }



Mime
View raw message