Hello, I wanted to calculate some statistics and I
decided to use libjudy vs a normal array to practise
using it. Unfortunately I get an error when compiling
and I get some very wierd results when running.
I'm including the c source and the errors plus usage info.
Thanks for your help.
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <Judy.h>
#define MAX (2^(8*sizeof(PWord_t)))-1
int main(void)
{
Pvoid_t jarray = (Pvoid_t)NULL;
PWord_t val;
PWord_t i;
PWord_t index;
unsigned char *errstr;
signed int ret;
const unsigned char fifo_name[] = \
"/tmp/0ds824bg9vn2y78gjhv197tvbv87134brv9z7612hb9vz";
FILE *fifo;
for(i = 0; i <= 255; i++)
{
JLI(val, jarray, i);
if(val == PJERR)
{
printf("Judy could not get enough memory.\n");
exit(1);
}
}
errno=0;
(void)mkfifo(fifo_name, S_IRUSR | S_IWUSR);
if(errno)
{
errstr = strerror(errno);
perror(errstr);
exit(1);
}
printf("Stick data into fifo %s\n", fifo_name);
fifo = fopen(fifo_name, "r");
if(errno)
{
errstr = strerror(errno);
perror(errstr);
exit(1);
}
index = getc(fifo);
if(index == EOF)
{
printf("fifo has 0 bytes of data in it.\n");
exit(1);
}
i=0;
do
{
JLG(val, jarray, index);
if(val == PJERR)
{
printf("Judy could not get enough memory.\n");
exit(1);
}
val++;
i++;
index = getc(fifo);
} while(index != EOF && i != MAX);
if(i == MAX)
{
printf("Had to stop counting because I was " \
"about to experience a type overflow.\n" );
}
(void)fclose(fifo);
(void)unlink(fifo_name);
printf("Byte value\tcount\n");
for(index = 0; index <= 255; index++)
{
JLG(val, jarray, index);
if(val == PJERR)
{
printf("Judy could not get enough memory.\n");
exit(1);
}
printf("%i\t\t%lli\n", index, val);
}
printf("\nTotal %i bytes processed.\n", i);
JLFA(val, jarray);
return(0);
}
entropy-calc.c: In function âmainâ:
entropy-calc.c:25:18: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:27:9: warning: passing argument 2 of âJudyLInsâ makes
integer from pointer without a cast [enabled by default]
In file included from entropy-calc.c:7:0:
/usr/include/Judy.h:246:17: note: expected âWord_tâ but argument is of type
âPWord_tâ
entropy-calc.c:41:16: warning: assignment makes pointer from integer without a
cast [enabled by default]
entropy-calc.c:52:16: warning: assignment makes pointer from integer without a
cast [enabled by default]
entropy-calc.c:57:11: warning: assignment makes pointer from integer without a
cast [enabled by default]
entropy-calc.c:59:14: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:69:9: warning: passing argument 2 of âJudyLGetâ makes
integer from pointer without a cast [enabled by default]
In file included from entropy-calc.c:7:0:
/usr/include/Judy.h:245:17: note: expected âWord_tâ but argument is of type
âPWord_tâ
entropy-calc.c:79:15: warning: assignment makes pointer from integer without a
cast [enabled by default]
entropy-calc.c:81:19: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:81:31: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:83:10: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:94:26: warning: comparison between pointer and integer [enabled
by default]
entropy-calc.c:96:9: warning: passing argument 2 of âJudyLGetâ makes
integer from pointer without a cast [enabled by default]
In file included from entropy-calc.c:7:0:
/usr/include/Judy.h:245:17: note: expected âWord_tâ but argument is of type
âPWord_tâ
entropy-calc.c:109:5: warning: assignment makes pointer from integer without a
cast [enabled by default]
entropy-calc.c:109:5: warning: comparison between pointer and integer [enabled
by default]
dd bs=4096 if=/dev/sda of=/tmp/0ds824bg9vn2y78gjhv197tvbv87134brv9z7612hb9vz
skip=1 count=$((49000000000/4096))
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel