text stringlengths 0 357 |
|---|
} |
if (tokens != NULL) { |
for (i = parser->toknext - 1; i >= 0; i--) { |
/* Unmatched opened object or array */ |
if (tokens[i].start != -1 && tokens[i].end == -1) { |
return JSMN_ERROR_PART; |
} |
} |
} |
return count; |
} |
/** |
* Creates a new parser based over a given buffer with an array of tokens |
* available. |
*/ |
void jsmn_init(jsmn_parser *parser) { |
parser->pos = 0; |
parser->toknext = 0; |
parser->toksuper = -1; |
} |
``` |
Filename: dc_key.c |
```c |
#include <ctype.h> |
#include <memory.h> |
#include "dc_context.h" |
#include "dc_key.h" |
#include "dc_pgp.h" |
#include "dc_tools.h" |
void dc_wipe_secret_mem(void* buf, size_t buf_bytes) |
{ |
/* wipe private keys or othere secrets with zeros so that secrets are no longer in RAM */ |
if (buf==NULL || buf_bytes <= 0) { |
return; |
} |
memset(buf, 0x00, buf_bytes); |
} |
static void dc_key_empty(dc_key_t* key) /* only use before calling setters; take care when using this function together with reference counting, prefer new objects instead */ |
{ |
if (key==NULL) { |
return; |
} |
if (key->type==DC_KEY_PRIVATE) { |
dc_wipe_secret_mem(key->binary, key->bytes); |
} |
free(key->binary); |
key->binary = NULL; |
key->bytes = 0; |
key->type = DC_KEY_PUBLIC; |
} |
dc_key_t* dc_key_new() |
{ |
dc_key_t* key; |
if ((key=calloc(1, sizeof(dc_key_t)))==NULL) { |
exit(44); /* cannot allocate little memory, unrecoverable error */ |
} |
key->_m_heap_refcnt = 1; |
return key; |
} |
dc_key_t* dc_key_ref(dc_key_t* key) |
{ |
if (key==NULL) { |
return NULL; |
} |
key->_m_heap_refcnt++; |
return key; |
} |
void dc_key_unref(dc_key_t* key) |
{ |
if (key==NULL) { |
return; |
} |
key->_m_heap_refcnt--; |
if (key->_m_heap_refcnt != 0) { |
return; |
} |
dc_key_empty(key); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.