"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/lib/r_assoc.c" between
ssldump-0.9b3.tar.gz and ssldump-1.3.tar.gz

About: ssldump is an SSLv3/TLS network protocol analyzer.

r_assoc.c  (ssldump-0.9b3):r_assoc.c  (ssldump-1.3)
skipping to change at line 55 skipping to change at line 55
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMA GE. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMA GE.
$Id: r_assoc.c,v 1.4 2001/12/24 06:06:26 ekr Exp $ $Id: r_assoc.c,v 1.4 2001/12/24 06:06:26 ekr Exp $
ekr@rtfm.com Sun Jan 17 17:57:15 1999 ekr@rtfm.com Sun Jan 17 17:57:15 1999
*/ */
static char *RCSSTRING="$Id: r_assoc.c,v 1.4 2001/12/24 06:06:26 ekr Exp $";
#include <r_common.h> #include <r_common.h>
#include "r_assoc.h" #include "r_assoc.h"
typedef struct r_assoc_el_ { typedef struct r_assoc_el_ {
char *key; char *key;
int key_len; int key_len;
void *data; void *data;
struct r_assoc_el_ *prev; struct r_assoc_el_ *prev;
struct r_assoc_el_ *next; struct r_assoc_el_ *next;
int (*copy) PROTO_LIST((void **new,void *old)); int (*copy) PROTO_LIST((void **new,void *old));
skipping to change at line 123 skipping to change at line 121
r_assoc *assoc; r_assoc *assoc;
int i; int i;
if(!assocp || !*assocp) if(!assocp || !*assocp)
return(0); return(0);
assoc=*assocp; assoc=*assocp;
for(i=0;i<assoc->size;i++) for(i=0;i<assoc->size;i++)
destroy_assoc_chain(assoc->chains[i]); destroy_assoc_chain(assoc->chains[i]);
free(assoc->chains);
free(assoc);
return(0); return(0);
} }
static int destroy_assoc_chain(chain) static int destroy_assoc_chain(chain)
r_assoc_el *chain; r_assoc_el *chain;
{ {
r_assoc_el *nxt; r_assoc_el *nxt;
while(chain){ while(chain){
nxt=chain->next; nxt=chain->next;
skipping to change at line 175 skipping to change at line 176
else{ else{
ptr->next=tmp; ptr->next=tmp;
tmp->prev=ptr; tmp->prev=ptr;
ptr=tmp; ptr=tmp;
} }
ptr->destroy=old->destroy; ptr->destroy=old->destroy;
ptr->copy=old->copy; ptr->copy=old->copy;
if(old->copy){ if(old->copy){
if(r=old->copy(&ptr->data,old->data)) if((r=old->copy(&ptr->data,old->data)))
ABORT(r); ABORT(r);
} }
else else
ptr->data=old->data; ptr->data=old->data;
if(!(ptr->key=(char *)malloc(old->key_len))) if(!(ptr->key=(char *)malloc(old->key_len)))
ABORT(R_NO_MEMORY); ABORT(R_NO_MEMORY);
memcpy(ptr->key,old->key,ptr->key_len=old->key_len); memcpy(ptr->key,old->key,ptr->key_len=old->key_len);
} }
skipping to change at line 226 skipping to change at line 227
int r_assoc_fetch(assoc,key,len,datap) int r_assoc_fetch(assoc,key,len,datap)
r_assoc *assoc; r_assoc *assoc;
char *key; char *key;
int len; int len;
void **datap; void **datap;
{ {
r_assoc_el *bucket; r_assoc_el *bucket;
int r; int r;
if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){ if((r=r_assoc_fetch_bucket(assoc,key,len,&bucket))){
if(r!=R_NOT_FOUND) if(r!=R_NOT_FOUND)
ERETURN(r); ERETURN(r);
return(r); return(r);
} }
*datap=bucket->data; *datap=bucket->data;
return(0); return(0);
} }
int r_assoc_insert(assoc,key,len,data,copy,destroy,how) int r_assoc_insert(assoc,key,len,data,copy,destroy,how)
skipping to change at line 248 skipping to change at line 249
char *key; char *key;
int len; int len;
void *data; void *data;
int (*copy) PROTO_LIST((void **new,void *old)); int (*copy) PROTO_LIST((void **new,void *old));
int (*destroy) PROTO_LIST((void *ptr)); int (*destroy) PROTO_LIST((void *ptr));
int how; int how;
{ {
r_assoc_el *bucket,*new_bucket=0; r_assoc_el *bucket,*new_bucket=0;
int r,_status; int r,_status;
if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){ if((r=r_assoc_fetch_bucket(assoc,key,len,&bucket))){
/*Note that we compute the hash value twice*/ /*Note that we compute the hash value twice*/
UINT4 hash_value; UINT4 hash_value;
if(r!=R_NOT_FOUND) if(r!=R_NOT_FOUND)
ABORT(r); ABORT(r);
hash_value=hash_compute(key,len,assoc->bits); hash_value=hash_compute(key,len,assoc->bits);
if(!(new_bucket=(r_assoc_el *)calloc(sizeof(r_assoc_el),1))) if(!(new_bucket=(r_assoc_el *)calloc(sizeof(r_assoc_el),1)))
ABORT(R_NO_MEMORY); ABORT(R_NO_MEMORY);
if(!(new_bucket->key=(char *)malloc(len))) if(!(new_bucket->key=(char *)malloc(len)))
skipping to change at line 299 skipping to change at line 300
} }
int r_assoc_copy(newp,old) int r_assoc_copy(newp,old)
r_assoc **newp; r_assoc **newp;
r_assoc *old; r_assoc *old;
{ {
int r,_status,i; int r,_status,i;
r_assoc *new; r_assoc *new;
if(!(new=(r_assoc *)calloc(sizeof(r_assoc),1))) if(!(new=(r_assoc *)calloc(sizeof(r_assoc),1)))
ABORT(r); ABORT(R_NO_MEMORY);
new->size=old->size; new->size=old->size;
new->bits=old->bits; new->bits=old->bits;
if(!(new->chains=(r_assoc_el **)calloc(sizeof(r_assoc_el),old->size))) if(!(new->chains=(r_assoc_el **)calloc(sizeof(r_assoc_el),old->size)))
ABORT(R_NO_MEMORY); ABORT(R_NO_MEMORY);
for(i=0;i<new->size;i++){ for(i=0;i<new->size;i++){
if(r=copy_assoc_chain(new->chains+i,old->chains[i])) if((r=copy_assoc_chain(new->chains+i,old->chains[i])))
ABORT(r); ABORT(R_NO_MEMORY);
} }
*newp=new; *newp=new;
_status=0; _status=0;
abort: abort:
if(_status){ if(_status){
r_assoc_destroy(&new); r_assoc_destroy(&new);
} }
return(_status); return(_status);
} }
 End of changes. 7 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)