src/growing_buf.c
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 2840 b881c48c9e9d
child 4792 7056435ab9e7
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #include "pEp_internal.h"
     5 #include "growing_buf.h"
     6 
     7 growing_buf_t *new_growing_buf(void)
     8 {
     9     growing_buf_t *result = calloc(1, sizeof(growing_buf_t));
    10     assert(result);
    11     return result;
    12 }
    13 
    14 void free_growing_buf(growing_buf_t *buf)
    15 {
    16     if (buf) {
    17         free(buf->data);
    18         free(buf);
    19     }
    20 }
    21 
    22 int growing_buf_consume(const void *src, size_t size, growing_buf_t *dst)
    23 {
    24     assert(src && dst);
    25     if (!(src && dst))
    26         return -1;
    27 
    28     char *new_data = realloc(dst->data, dst->size + size + 1);
    29     assert(new_data);
    30     if (!new_data)
    31         return -1;
    32     dst->data = new_data;
    33     memcpy(dst->data + dst->size, src, size);
    34     dst->size += size;
    35     dst->data[dst->size] = 0; // safeguard
    36 
    37     return 1;
    38 }
    39