print what we inserting into cache during test. fixed all gcc warnings.

This commit is contained in:
Radim Kolar 2009-09-22 18:16:28 +02:00
parent 1f570b0049
commit c45f3e0794

View File

@ -9,8 +9,11 @@
#include <stdlib.h> #include <stdlib.h>
#include "../server/fifocache.h" #include "../server/fifocache.h"
static int intcompare(const int *i1,const int *i2) static int intcompare(const void *vi1,const void *vi2)
{ {
const int *i1,*i2;
i1 = vi1;
i2 = vi2;
if(i1==NULL || i2==NULL) return 1; if(i1==NULL || i2==NULL) return 1;
if(*i1==*i2) return 0; if(*i1==*i2) return 0;
return 1; return 1;
@ -41,27 +44,31 @@ int main(int argv,char **argc)
{ {
struct FifoCache * cache; struct FifoCache * cache;
char file[20]; char file[20];
char *s; const char *s;
int i; int i;
cache=f_cache_new(4,sizeof(file),NULL,sizeof(int),NULL,intcompare); cache=f_cache_new(4,sizeof(file),NULL,sizeof(int),NULL,intcompare);
assert(cache!=NULL); assert(cache!=NULL);
strcpy(file,"/jeden/soubor"); strcpy(file,"/jeden/soubor");
i=1; i=1;
printf("Puting key %d: %s\n",i,file);
f_cache_put(cache,&i,file); f_cache_put(cache,&i,file);
strcpy(file,"/druhy"); strcpy(file,"/druhy");
i=2; i=2;
printf("Puting key %d: %s\n",i,file);
f_cache_put(cache,&i,file); f_cache_put(cache,&i,file);
strcpy(file,"/treti"); strcpy(file,"/treti");
i=3; i=3;
printf("Puting key %d: %s\n",i,file);
f_cache_put(cache,&i,file); f_cache_put(cache,&i,file);
strcpy(file,"/ctvrty/soubor"); strcpy(file,"/ctvrty/soubor");
i=4; i=4;
printf("Puting key %d: %s\n",i,file);
f_cache_put(cache,&i,file); f_cache_put(cache,&i,file);
for(i=0;i<=5;i++) for(i=0;i<=5;i++)
{ {
printf("Finding key %d: %s\n",i,f_cache_find(cache,&i)); printf("Finding key %d: %s\n",i,(char *)f_cache_find(cache,&i));
} }
f_cache_clear(cache); f_cache_clear(cache);
f_cache_destroy(cache); f_cache_destroy(cache);
@ -74,9 +81,9 @@ int main(int argv,char **argc)
s="lamer2"; s="lamer2";
f_cache_put(cache,&s,NULL); f_cache_put(cache,&s,NULL);
s="lamer co tu neni"; s="lamer co tu neni";
printf("find2: %s\n",f_cache_find(cache,&s)); printf("find2: %s\n",(char *)f_cache_find(cache,&s));
s="lamer1"; s="lamer1";
printf("find2: %s\n",f_cache_find(cache,&s)); printf("find2: %s\n",(char *)f_cache_find(cache,&s));
return 0; return 0;
} }