Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbor_encoder_create_array() returns CborErrorOutOfMemory (0x80000000) #163

Open
StefanHri opened this issue Sep 2, 2019 · 1 comment
Open

Comments

@StefanHri
Copy link

StefanHri commented Sep 2, 2019

Hi,
the code bellow causes that cbor_encoder_create_array returns CborErrorOutOfMemory.

CborEncoder enc, array_enc;
u8_t buf[16];
cbor_encoder_init(&enc, buf, sizeof(buf), 0);
int res = 0;
res = cbor_encoder_create_array(&enc, &array_enc, 1);

How to create a CBOR array? Can you point me to some example. Thank you!

@thiagomacieira
Copy link
Member

You've got the right code. This prints 0 for me:

#include <cbor.h>
#include <stdint.h>

int main()
{
    CborEncoder enc, array_enc;
    uint8_t buf[16];
    cbor_encoder_init(&enc, buf, sizeof(buf), 0);
    int res = 0;
    res = cbor_encoder_create_array(&enc, &array_enc, 1);
    printf("%x\n", res);
}

Can you give me a more complete example that does fail for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants