tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/src/native/common jk_context.c jk_context.h
Date Fri, 01 Jun 2001 21:47:41 GMT
hgomez      01/06/01 14:47:41

  Modified:    jk/src/native/common jk_context.c jk_context.h
  Log:
  Updated stuff on context
  Work on progress
  
  Revision  Changes    Path
  1.2       +42 -4     jakarta-tomcat-connectors/jk/src/native/common/jk_context.c
  
  Index: jk_context.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/src/native/common/jk_context.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_context.c	2001/06/01 09:59:07	1.1
  +++ jk_context.c	2001/06/01 21:47:40	1.2
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Context handling (Autoconf)                                *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.1 $                                           *
  + * Version:     $Revision: 1.2 $                                           *
    ***************************************************************************/
   
   #include "jk_global.h"
  @@ -74,7 +74,8 @@
   		c->virtual  = NULL;
   		c->cbase  	= NULL,
           c->status   = AJP14_CONTEXT_DOWN;
  -        c->nuri  	= 0;
  +        c->size  	= 0;
  +        c->capacity = 0;
           c->uris     = NULL;
           return JK_TRUE;
       }
  @@ -154,6 +155,30 @@
   	return NULL;
   }
   
  +/*
  + * Context Memory Managment
  + */
  +
  +static int context_realloc(jk_context_t *c)
  +{
  +    if (c->size == c->capacity) {
  +        char **uris;
  +        int  capacity = c->capacity + CONTEXT_INC_SIZE;
  +
  +        uris = (char **)jk_pool_alloc(&c->p, sizeof(char *) * capacity);
  +
  +        if (! uris)
  +			return JK_FALSE;
  +
  +		memcpy(uris, c->uris, sizeof(char *) * c->capacity);
  +
  +        c->uris = uris;
  +        c->capacity = capacity;
  +    }
  +
  +    return JK_TRUE;
  +}
  +
   
   /*
    * Add an URI to context
  @@ -163,10 +188,23 @@
   {
       int i;
   
  -    if (! c)
  +    if (! c || ! uri)
           return JK_FALSE;
   
  -    return NULL;
  +	for (i = 0 ; i < c->size ; i++) {
  +		if (! strcmp(c->uris[i], uri)) {
  +                return JK_TRUE;
  +            }
  +        }
  +
  +	context_realloc(c);
  +
  +	if (c->size >= c->capacity) 
  +		return JK_FALSE;
  +
  +	c->uris[c->size] = jk_pool_strdup(&c->p, uri);
  +	c->size++;
  +	return JK_TRUE;
   }
   
   
  
  
  
  1.2       +10 -2     jakarta-tomcat-connectors/jk/src/native/common/jk_context.h
  
  Index: jk_context.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/src/native/common/jk_context.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_context.h	2001/06/01 09:59:07	1.1
  +++ jk_context.h	2001/06/01 21:47:40	1.2
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Context Stuff (Autoconf)                                   *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.1 $                                           *
  + * Version:     $Revision: 1.2 $                                           *
    ***************************************************************************/
   #ifndef JK_CONTEXT_H
   #define JK_CONTEXT_H
  @@ -67,6 +67,8 @@
   extern "C" {
   #endif /* __cplusplus */
   
  +#define CONTEXT_INC_SIZE (50)
  +
   typedef struct {
   
   	/*
  @@ -97,8 +99,14 @@
   	/*
   	 * Num of URI handled 
   	 */
  +	
  +	int			size;
  +
  +	/*
  +	 * Capacity
  +	 */
   	
  -	int			nuri;
  +	int			capacity;
   
   	/*
   	 * URL/URIs (autoconf)
  
  
  

Mime
View raw message