[or-cvs] cleanup: don"t use size_t when you mean int

Roger Dingledine arma at seul.org
Sat Aug 24 04:59:24 UTC 2002


Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or

Modified Files:
	buffers.c circuit.c main.c onion.c or.h routers.c 
Log Message:
cleanup: don't use size_t when you mean int

size_t is what you get back from sizeof(). no more, no less.



Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- buffers.c	23 Aug 2002 06:49:43 -0000	1.7
+++ buffers.c	24 Aug 2002 04:59:21 -0000	1.8
@@ -8,7 +8,7 @@
 
 extern or_options_t options; /* command-line and config-file options */
 
-int buf_new(char **buf, size_t *buflen, size_t *buf_datalen) {
+int buf_new(char **buf, int *buflen, int *buf_datalen) {
 
   assert(buf && buflen && buf_datalen);
 
@@ -26,7 +26,7 @@
   free(buf);
 }
 
-int read_to_buf(int s, int at_most, char **buf, size_t *buflen, size_t *buf_datalen, int *reached_eof) {
+int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, int *reached_eof) {
 
   /* read from socket s, writing onto buf+buf_datalen. If at_most is >= 0 then
    * read at most 'at_most' bytes, and in any case don't read more than will fit based on buflen.
@@ -48,8 +48,8 @@
     return 0; /* we shouldn't read anything */
 
   if(!options.LinkPadding && at_most > 10*sizeof(cell_t)) {
-    /* if no linkpadding. do a rudimentary round-robin so one
-     * connection can't hog our receiver bucket
+    /* if no linkpadding: do a rudimentary round-robin so one
+     * connection can't hog an outgoing connection
      */
     at_most = 10*sizeof(cell_t);
   }
@@ -73,7 +73,7 @@
 
 }
 
-int flush_buf(int s, char **buf, size_t *buflen, size_t *buf_flushlen, size_t *buf_datalen) {
+int flush_buf(int s, char **buf, int *buflen, int *buf_flushlen, int *buf_datalen) {
 
   /* push from buf onto s
    * then memmove to front of buf
@@ -105,8 +105,8 @@
   }
 }
 
-int write_to_buf(char *string, size_t string_len,
-                 char **buf, size_t *buflen, size_t *buf_datalen) {
+int write_to_buf(char *string, int string_len,
+                 char **buf, int *buflen, int *buf_datalen) {
 
   /* append string to buf (growing as needed, return -1 if "too big")
    * return total number of bytes on the buf
@@ -128,8 +128,8 @@
 
 }
 
-int fetch_from_buf(char *string, size_t string_len,
-                 char **buf, size_t *buflen, size_t *buf_datalen) {
+int fetch_from_buf(char *string, int string_len,
+                 char **buf, int *buflen, int *buf_datalen) {
 
   /* if there is string_len bytes in buf, write them onto string,
    * then memmove buf back (that is, remove them from buf) */

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- circuit.c	22 Aug 2002 07:30:03 -0000	1.10
+++ circuit.c	24 Aug 2002 04:59:21 -0000	1.11
@@ -80,7 +80,7 @@
   free(circ);
 }
 
-void circuit_free_cpath(crypt_path_t **cpath, size_t cpathlen) {
+void circuit_free_cpath(crypt_path_t **cpath, int cpathlen) {
   int i;
 
   for(i=0;i<cpathlen;i++)
@@ -296,7 +296,7 @@
   return connection_write_cell_to_buf(cell, conn);
 }
 
-int circuit_crypt(circuit_t *circ, char *in, size_t inlen, char crypt_type) {
+int circuit_crypt(circuit_t *circ, char *in, int inlen, char crypt_type) {
   char *out;
   int i;
   crypt_path_t *thishop;

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- main.c	23 Aug 2002 03:35:44 -0000	1.17
+++ main.c	24 Aug 2002 04:59:21 -0000	1.18
@@ -182,18 +182,18 @@
   return NULL;
 }
 
-routerinfo_t *router_get_first_in_route(unsigned int *route, size_t routelen) {
+routerinfo_t *router_get_first_in_route(unsigned int *route, int routelen) {
   return router_array[route[routelen-1]];
 }
 
 /* a wrapper around new_route. put all these in routers.c perhaps? */
-unsigned int *router_new_route(size_t *rlen) {
-  return new_route(options.CoinWeight, router_array,rarray_len, rlen);
+unsigned int *router_new_route(int *routelen) {
+  return new_route(options.CoinWeight, router_array, rarray_len, routelen);
 }
 
 /* a wrapper around create_onion */
-unsigned char *router_create_onion(unsigned int *route, size_t routelen, size_t *lenp, crypt_path_t **cpathp) {
-  return create_onion(router_array,rarray_len,route,routelen,lenp,cpathp);
+unsigned char *router_create_onion(unsigned int *route, int routelen, int *len, crypt_path_t **cpath) {
+  return create_onion(router_array,rarray_len,route,routelen,len,cpath);
 }
 
 

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- onion.c	23 Aug 2002 05:27:50 -0000	1.9
+++ onion.c	24 Aug 2002 04:59:21 -0000	1.10
@@ -92,23 +92,21 @@
  * int cw is the coin weight to use when choosing the route 
  * order of routers is from last to first
  */
-unsigned int *new_route(double cw, routerinfo_t **rarray, size_t rarray_len, size_t *rlen)
+unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen)
 {
-  int routelen = 0;
   int i, j;
   int num_acceptable_routers = 0;
-  int retval = 0;
   unsigned int *route = NULL;
   unsigned int oldchoice, choice;
   
-  assert((cw >= 0) && (cw < 1) && (rarray) && (rlen) ); /* valid parameters */
+  assert((cw >= 0) && (cw < 1) && (rarray) && (routelen) ); /* valid parameters */
 
-  routelen = chooselen(cw);
-  if (routelen == -1) {
+  *routelen = chooselen(cw);
+  if (*routelen == -1) {
     log(LOG_ERR,"Choosing route length failed.");
     return NULL;
   }
-  log(LOG_DEBUG,"new_route(): Chosen route length %d.",routelen);
+  log(LOG_DEBUG,"new_route(): Chosen route length %d.",*routelen);
 
   for(i=0;i<rarray_len;i++) {
     log(LOG_DEBUG,"Contemplating whether router %d is any good...",i);
@@ -128,28 +126,27 @@
     next_i_loop:
   }
       
-  if(num_acceptable_routers < routelen) {
-    log(LOG_DEBUG,"new_route(): Cutting routelen from %d to %d.",routelen, num_acceptable_routers);
-    routelen = num_acceptable_routers;
+  if(num_acceptable_routers < *routelen) {
+    log(LOG_DEBUG,"new_route(): Cutting routelen from %d to %d.",*routelen, num_acceptable_routers);
+    *routelen = num_acceptable_routers;
   }
 
-  if(routelen < 1) {
+  if(*routelen < 1) {
     log(LOG_ERR,"new_route(): Didn't find any acceptable routers. Failing.");
     return NULL;
   }
 
   /* allocate memory for the new route */
-  route = (unsigned int *)malloc(routelen * sizeof(unsigned int));
+  route = (unsigned int *)malloc(*routelen * sizeof(unsigned int));
   if (!route) {
     log(LOG_ERR,"Memory allocation failed.");
     return NULL;
   }
  
   oldchoice = rarray_len;
-  for(i=0;i<routelen;i++) {
+  for(i=0;i<*routelen;i++) {
     log(LOG_DEBUG,"new_route(): Choosing hop %u.",i);
-    retval = crypto_pseudo_rand(sizeof(unsigned int),(unsigned char *)&choice);
-    if (retval) {
+    if(crypto_pseudo_rand(sizeof(unsigned int),(unsigned char *)&choice)) {
       free((void *)route);
       return NULL;
     }
@@ -171,31 +168,30 @@
     route[i] = choice;
   }
    
-  *rlen = routelen;
   return route;
 }
 
-/* creates a new onion from route, stores it and its length into bufp and lenp respectively */
-unsigned char *create_onion(routerinfo_t **rarray, size_t rarray_len, unsigned int *route, size_t routelen, size_t *lenp, crypt_path_t **cpathp)
+/* creates a new onion from route, stores it and its length into buf and len respectively */
+unsigned char *create_onion(routerinfo_t **rarray, int rarray_len, unsigned int *route, int routelen, int *len, crypt_path_t **cpath)
 {
   int i,j;
   int retval = 0;
   onion_layer_t *layer = NULL;
   crypt_path_t *hop = NULL;
   unsigned char *retbuf = NULL;
-  unsigned char *bufp;
+  unsigned char *buf;
   routerinfo_t *router;
   unsigned char iv[16];
 
-  assert(rarray && route && lenp && routelen);
+  assert(rarray && route && len && routelen);
 
     /* calculate the size of the onion */
-    *lenp = routelen * 28 + 100; /* 28 bytes per layer + 100 bytes padding for the innermost layer */
-    log(LOG_DEBUG,"create_onion() : Size of the onion is %u.",*lenp);
+    *len = routelen * 28 + 100; /* 28 bytes per layer + 100 bytes padding for the innermost layer */
+    log(LOG_DEBUG,"create_onion() : Size of the onion is %u.",*len);
     
     /* allocate memory for the onion */
-    bufp = (unsigned char *)malloc(*lenp);
-    if (!bufp)
+    buf = (unsigned char *)malloc(*len);
+    if (!buf)
     {
       log(LOG_ERR,"Error allocating memory.");
       return NULL;
@@ -207,7 +203,7 @@
       log(LOG_DEBUG,"create_onion() : %u : %s:%u, %u/%u",routelen-retval,inet_ntoa(*((struct in_addr *)&((rarray[route[retval]])->addr))),ntohs((rarray[route[retval]])->or_port),(rarray[route[retval]])->pkey,crypto_pk_keysize((rarray[route[retval]])->pkey));
     }
     
-    layer = (onion_layer_t *)(bufp + *lenp - 128); /* pointer to innermost layer */
+    layer = (onion_layer_t *)(buf + *len - 128); /* pointer to innermost layer */
     /* create the onion layer by layer, starting with the innermost */
     for (i=0;i<routelen;i++)
     {
@@ -242,16 +238,16 @@
       if (retval) /* error */
       {
 	log(LOG_ERR,"Error generating random data.");
-	free((void *)bufp);
-	if (cpathp)
+	free((void *)buf);
+	if (cpath)
 	{
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
 	    
-	    free((void *)cpathp[i]);
+	    free((void *)cpath[i]);
 	  }
 	}
 	return NULL;
@@ -259,25 +255,25 @@
       log(LOG_DEBUG,"create_onion() : Onion layer %u built : %u, %u, %u, %s, %u.",i+1,layer->zero,layer->backf,layer->forwf,inet_ntoa(*((struct in_addr *)&layer->addr)),ntohs(layer->port));
       
       /* build up the crypt_path */
-      if (cpathp)
+      if (cpath)
       {
-	cpathp[i] = (crypt_path_t *)malloc(sizeof(crypt_path_t));
-	if (!cpathp[i])
+	cpath[i] = (crypt_path_t *)malloc(sizeof(crypt_path_t));
+	if (!cpath[i])
 	{
 	  log(LOG_ERR,"Error allocating memory.");
-	  free((void *)bufp);
+	  free((void *)buf);
           for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
 	    
-	    free((void *)cpathp[i]);
+	    free((void *)cpath[i]);
 	  }
 	}
       
 	log(LOG_DEBUG,"create_onion() : Building hop %u of crypt path.",i+1);
-	hop = cpathp[i];
+	hop = cpath[i];
 	/* set crypto functions */
 	hop->backf = layer->backf;
 	hop->forwf = layer->forwf;
@@ -309,13 +305,13 @@
 	if (!hop->f_crypto) /* cipher initialization failed */
 	{
 	  log(LOG_ERR,"Could not create a crypto environment.");
-	  free((void *)bufp);
+	  free((void *)buf);
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	  return NULL;
 	}
@@ -323,13 +319,13 @@
 	if (crypto_cipher_set_key(hop->f_crypto, hop->digest3) || 
 	    crypto_cipher_set_iv(hop->f_crypto, iv)) {
 	  log(LOG_ERR,"Could not initialize the crypto engine.");
-          free((void *)bufp);
+          free((void *)buf);
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	  return NULL;
 	}
@@ -349,13 +345,13 @@
 	if (!hop->b_crypto) /* cipher initialization failed */
 	{
 	  log(LOG_ERR,"Could not create a crypto environment.");
-	  free((void *)bufp);
+	  free((void *)buf);
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	  return NULL;
 	}
@@ -363,13 +359,13 @@
 	if (crypto_cipher_set_key(hop->b_crypto, hop->digest2) || 
 	    crypto_cipher_set_iv(hop->b_crypto, iv)) {
 	  log(LOG_ERR,"Could not initialize the crypto engine.");
-          free((void *)bufp);
+          free((void *)buf);
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	  return NULL;
 	}
@@ -377,13 +373,13 @@
         /* initialize */
 	if (crypto_cipher_encrypt_init_cipher(hop->f_crypto) || crypto_cipher_decrypt_init_cipher(hop->b_crypto)) {
 	  log(LOG_ERR,"Could not initialize the crypto engine.");
-	  free((void *)bufp);
+	  free((void *)buf);
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	  return NULL;
 	}
@@ -398,15 +394,15 @@
 	if (retval) /* error */
 	{
 	  log(LOG_ERR,"Error generating pseudo-random data.");
-	  free((void *)bufp);
-	  if (cpathp)
+	  free((void *)buf);
+	  if (cpath)
 	  {
 	    for (j=0;j<i;j++) {
-	      if (cpathp[i]->f_crypto)
-		crypto_free_cipher_env(cpathp[i]->f_crypto);
-	      if (cpathp[i]->b_crypto)
-		crypto_free_cipher_env(cpathp[i]->b_crypto);
-	      free((void *)cpathp[i]);
+	      if (cpath[i]->f_crypto)
+		crypto_free_cipher_env(cpath[i]->f_crypto);
+	      if (cpath[i]->b_crypto)
+		crypto_free_cipher_env(cpath[i]->b_crypto);
+	      free((void *)cpath[i]);
 	    }
 	  }
 	  return NULL;
@@ -419,15 +415,15 @@
       if (!retbuf)
       {
 	log(LOG_ERR,"Error encrypting onion layer.");
-	free((void *)bufp);
-	if (cpathp)
+	free((void *)buf);
+	if (cpath)
 	{
 	  for (j=0;j<i;j++) {
-	    if (cpathp[i]->f_crypto)
-	      crypto_free_cipher_env(cpathp[i]->f_crypto);
-	    if (cpathp[i]->b_crypto)
-	      crypto_free_cipher_env(cpathp[i]->b_crypto);
-	    free((void *)cpathp[i]);
+	    if (cpath[i]->f_crypto)
+	      crypto_free_cipher_env(cpath[i]->f_crypto);
+	    if (cpath[i]->b_crypto)
+	      crypto_free_cipher_env(cpath[i]->b_crypto);
+	    free((void *)cpath[i]);
 	  }
 	}
 	return NULL;
@@ -435,10 +431,10 @@
       log(LOG_DEBUG,"create_onion() : Encrypted layer.");
       
       /* calculate pointer to next layer */
-      layer = (onion_layer_t *)(bufp + (routelen-i-2)*sizeof(onion_layer_t));
+      layer = (onion_layer_t *)(buf + (routelen-i-2)*sizeof(onion_layer_t));
     }
 
-    return bufp;
+    return buf;
 }
 
 /* encrypts 128 bytes of the onion with the specified public key, the rest with 
@@ -624,7 +620,7 @@
 }
 
 /* delete first n bytes of the onion and pads the end with n bytes of random data */
-void pad_onion(unsigned char *onion, uint32_t onionlen, size_t n)
+void pad_onion(unsigned char *onion, uint32_t onionlen, int n)
 {
   if (onion) /* valid parameter */
   {

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- or.h	22 Aug 2002 07:30:03 -0000	1.14
+++ or.h	24 Aug 2002 04:59:21 -0000	1.15
@@ -144,14 +144,14 @@
   int marked_for_close;
 
   char *inbuf;
-  size_t inbuflen;
-  size_t inbuf_datalen;
+  int inbuflen;
+  int inbuf_datalen;
   int inbuf_reached_eof;
 
   char *outbuf;
-  size_t outbuflen; /* how many bytes are allocated for the outbuf? */
-  size_t outbuf_flushlen; /* how much data should we try to flush from the outbuf? */
-  size_t outbuf_datalen; /* how much data is there total on the outbuf? */
+  int outbuflen; /* how many bytes are allocated for the outbuf? */
+  int outbuf_flushlen; /* how much data should we try to flush from the outbuf? */
+  int outbuf_datalen; /* how much data is there total on the outbuf? */
 
 //  uint16_t aci; /* anonymous connection identifier */
 
@@ -263,7 +263,7 @@
   crypto_cipher_env_t *n_crypto;
 
   crypt_path_t **cpath;
-  size_t cpathlen; 
+  int cpathlen; 
 
   uint32_t expire; /* expiration time for the corresponding onion */
 
@@ -318,26 +318,26 @@
 
 /********************************* buffers.c ***************************/
 
-int buf_new(char **buf, size_t *buflen, size_t *buf_datalen);
+int buf_new(char **buf, int *buflen, int *buf_datalen);
 
 void buf_free(char *buf);
 
-int read_to_buf(int s, int at_most, char **buf, size_t *buflen, size_t *buf_datalen, int *reached_eof);
+int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, int *reached_eof);
   /* grab from s, put onto buf, return how many bytes read */
 
-int flush_buf(int s, char **buf, size_t *buflen, size_t *buf_flushlen, size_t *buf_datalen);
+int flush_buf(int s, char **buf, int *buflen, int *buf_flushlen, int *buf_datalen);
   /* push from buf onto s
    * then memmove to front of buf
    * return -1 or how many bytes remain on the buf */
 
-int write_to_buf(char *string, size_t string_len,
-                 char **buf, size_t *buflen, size_t *buf_datalen);
+int write_to_buf(char *string, int string_len,
+                 char **buf, int *buflen, int *buf_datalen);
   /* append string to buf (growing as needed, return -1 if "too big")
    * return total number of bytes on the buf
    */
 
-int fetch_from_buf(char *string, size_t string_len,
-		                 char **buf, size_t *buflen, size_t *buf_datalen);
+int fetch_from_buf(char *string, int string_len,
+		                 char **buf, int *buflen, int *buf_datalen);
 	  /* if there is string_len bytes in buf, write them onto string,
 	  *    * then memmove buf back (that is, remove them from buf) */
 
@@ -360,11 +360,11 @@
 circuit_t *circuit_get_by_naddr_nport(uint32_t naddr, uint16_t nport);
 
 int circuit_deliver_data_cell(cell_t *cell, circuit_t *circ, connection_t *conn, int crypt_type);
-int circuit_crypt(circuit_t *circ, char *in, size_t inlen, char crypt_type);
+int circuit_crypt(circuit_t *circ, char *in, int inlen, char crypt_type);
 
 int circuit_init(circuit_t *circ, int aci_type);
 void circuit_free(circuit_t *circ);
-void circuit_free_cpath(crypt_path_t **cpath, size_t cpathlen);
+void circuit_free_cpath(crypt_path_t **cpath, int cpathlen);
 
 void circuit_close(circuit_t *circ);
 
@@ -517,9 +517,9 @@
 connection_t *connection_get_by_type(int type);
 
 routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port);
-unsigned int *router_new_route(size_t *rlen);
-unsigned char *router_create_onion(unsigned int *route, size_t routelen, size_t *lenp, crypt_path_t **cpathp);
-routerinfo_t *router_get_first_in_route(unsigned int *route, size_t routelen);
+unsigned int *router_new_route(int *routelen);
+unsigned char *router_create_onion(unsigned int *route, int routelen, int *len, crypt_path_t **cpath);
+routerinfo_t *router_get_first_in_route(unsigned int *route, int routelen);
 connection_t *connect_to_router_as_op(routerinfo_t *router);
 
 void connection_watch_events(connection_t *conn, short events);
@@ -552,10 +552,10 @@
  * int cw is the coin weight to use when choosing the route 
  * order of routers is from last to first
  */
-unsigned int *new_route(double cw, routerinfo_t **rarray, size_t rarray_len, size_t *rlen);
+unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen);
 
 /* creates a new onion from route, stores it and its length into bufp and lenp respectively */
-unsigned char *create_onion(routerinfo_t **rarray, size_t rarray_len, unsigned int *route, size_t routelen, size_t *lenp, crypt_path_t **cpathp);
+unsigned char *create_onion(routerinfo_t **rarray, int rarray_len, unsigned int *route, int routelen, int *len, crypt_path_t **cpath);
 
 /* encrypts 128 bytes of the onion with the specified public key, the rest with 
  * DES OFB with the key as defined in the outter layer */
@@ -565,7 +565,7 @@
 unsigned char *decrypt_onion(onion_layer_t *onion, uint32_t onionlen, crypto_pk_env_t *prkey);
 
 /* delete first n bytes of the onion and pads the end with n bytes of random data */
-void pad_onion(unsigned char *onion, uint32_t onionlen, size_t n);
+void pad_onion(unsigned char *onion, uint32_t onionlen, int n);
 
 /* create a new tracked_onion entry */
 tracked_onion_t *new_tracked_onion(unsigned char *onion, uint32_t onionlen, tracked_onion_t **tracked_onions, tracked_onion_t **last_tracked_onion);
@@ -578,10 +578,10 @@
 
 /********************************* routers.c ***************************/
 
-routerinfo_t **getrouters(char *routerfile, size_t *listlenp, uint16_t or_listenport);
+routerinfo_t **getrouters(char *routerfile, int *listlenp, uint16_t or_listenport);
 void delete_routerlist(routerinfo_t *list);
 /* create an NULL-terminated array of pointers pointing to elements of a router list */
-routerinfo_t **make_rarray(routerinfo_t* list, size_t *listlenp);
+routerinfo_t **make_rarray(routerinfo_t* list, int *len);
 
 
 #endif

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- routers.c	22 Aug 2002 07:30:03 -0000	1.6
+++ routers.c	24 Aug 2002 04:59:21 -0000	1.7
@@ -74,7 +74,7 @@
 /* create a NULL-terminated array of pointers pointing to elements of a router list */
 /* this is done in two passes through the list - inefficient but irrelevant as this is
  * only done once when op/or start up */
-routerinfo_t **make_rarray(routerinfo_t* list, size_t *len)
+routerinfo_t **make_rarray(routerinfo_t* list, int *len)
 {
   routerinfo_t *tmp=NULL;
   int listlen = 0;
@@ -116,7 +116,7 @@
 }
 
 /* load the router list */
-routerinfo_t **getrouters(char *routerfile, size_t *lenp, uint16_t or_listenport)
+routerinfo_t **getrouters(char *routerfile, int *len, uint16_t or_listenport)
 {
   int retval = 0;
   char *retp = NULL;
@@ -128,7 +128,7 @@
   char *errtest; /* detecting errors in strtoul() calls */
   struct hostent *rent;
 
-  assert(routerfile && lenp);
+  assert(routerfile && len);
   
   if (strcspn(routerfile,CONFIG_LEGAL_FILENAME_CHARACTERS) != 0) {
     log(LOG_ERR,"Filename %s contains illegal characters.",routerfile);
@@ -414,6 +414,6 @@
   }
   
   fclose(rf);
-  return make_rarray(routerlist, lenp);
+  return make_rarray(routerlist, len);
 }
 



More information about the tor-commits mailing list