diff options
author | 2019-11-14 21:11:34 +0000 | |
---|---|---|
committer | 2019-11-14 21:11:34 +0000 | |
commit | da0d961c2c28322a016c9e47e9898b8a67695a06 (patch) | |
tree | 98cc58b7052570a785fb26702de946f8f6519f3a /lib/libcbor/src/cbor/internal/stack.c | |
parent | Add missing cross-reference to NOTES section. (diff) | |
download | wireguard-openbsd-da0d961c2c28322a016c9e47e9898b8a67695a06.tar.xz wireguard-openbsd-da0d961c2c28322a016c9e47e9898b8a67695a06.zip |
Add libcbor; an implementation of the Concise Binary Object
Representation (CBOR) encoding format defined in RFC7049.
This is a dependency of libfido2, that we'll use for U2F/FIDO
support in OpenSSH.
feedback and "Looks good enough to me" deraadt@
Diffstat (limited to 'lib/libcbor/src/cbor/internal/stack.c')
-rw-r--r-- | lib/libcbor/src/cbor/internal/stack.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/libcbor/src/cbor/internal/stack.c b/lib/libcbor/src/cbor/internal/stack.c new file mode 100644 index 00000000000..65e15fe9379 --- /dev/null +++ b/lib/libcbor/src/cbor/internal/stack.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014-2017 Pavel Kalvoda <me@pavelkalvoda.com> + * + * libcbor is free software; you can redistribute it and/or modify + * it under the terms of the MIT license. See LICENSE for details. + */ + +#include "stack.h" + +struct _cbor_stack _cbor_stack_init() +{ + return (struct _cbor_stack) {.top = NULL, .size = 0}; +} + +void _cbor_stack_pop(struct _cbor_stack *stack) +{ + struct _cbor_stack_record *top = stack->top; + stack->top = stack->top->lower; + _CBOR_FREE(top); + stack->size--; +} + +struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *stack, cbor_item_t *item, size_t subitems) +{ + struct _cbor_stack_record *new_top = _CBOR_MALLOC(sizeof(struct _cbor_stack_record)); + if (new_top == NULL) + return NULL; + + *new_top = (struct _cbor_stack_record) {stack->top, item, subitems}; + stack->top = new_top; + stack->size++; + return new_top; +} |