pocdb
pocdb copied to clipboard
Example of pocdb_get()
Can you show an example of using the pocdb_get() function? I used it using the following code:
pocdb_client* c = pocdb_create();
char* key = (char*)malloc(sizeof(char)*100);
char **vals = (char **) malloc (sizeof (char *));
*vals = (char *) malloc (sizeof(char)*100);
size_t *val_len = (size_t *) malloc (sizeof(size_t)*20);
cin>>key;
if (pocdb_get(c, key, strlen(key), vals, val_len) != POCDB_SUCCESS)
{
std::cerr << "Get failure" << std::endl;
return EXIT_FAILURE;
}
else
{
std::cout << "VALUE : " << *vals << std::endl;
}
However, it prints a non-ASCII output. Like this. VALUE : ���
Without seeing the full code used to populate the DB, I cannot give you a concrete reason why it's doing this. I can speculate:
- Something went wrong on populate and it was populated with non-ASCII values.
- There's an error in the pack/unpack of values.
Given that this was written in 3 hours as a challenge to myself, I suspect it's very likely a bug in the code and it'd probably be instructive to trace what's happening and find out.
I'm happy to back and forth on that if you have more information for me to work with.