pocdb icon indicating copy to clipboard operation
pocdb copied to clipboard

Example of pocdb_get()

Open vinaymundada27 opened this issue 7 years ago • 1 comments

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 : ���

vinaymundada27 avatar Apr 17 '18 17:04 vinaymundada27

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:

  1. Something went wrong on populate and it was populated with non-ASCII values.
  2. 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.

rescrv avatar Apr 18 '18 01:04 rescrv