libcoap  4.3.0
encode.h File Reference
#include <strings.h>
#include <stdint.h>
+ Include dependency graph for encode.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int coap_fls (unsigned int i)
 
int coap_flsll (long long i)
 
unsigned int coap_decode_var_bytes (const uint8_t *buf, size_t length)
 Decodes multiple-length byte sequences. More...
 
uint64_t coap_decode_var_bytes8 (const uint8_t *buf, size_t length)
 Decodes multiple-length byte sequences. More...
 
unsigned int coap_encode_var_safe (uint8_t *buf, size_t length, unsigned int value)
 Encodes multiple-length byte sequences. More...
 
unsigned int coap_encode_var_safe8 (uint8_t *buf, size_t length, uint64_t value)
 Encodes multiple-length byte sequences. More...
 
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes (uint8_t *buf, unsigned int value)
 

Function Documentation

◆ coap_encode_var_bytes()

COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes ( uint8_t *  buf,
unsigned int  value 
)
Deprecated:
Use coap_encode_var_safe() instead.

Provided for backward compatibility. As value has a maximum value of 0xffffffff, and buf is usually defined as an array, it is unsafe to continue to use this variant if buf[] is less than buf[4].

For example char buf[1],oops; .. coap_encode_var_bytes(buf, 0xfff); would cause oops to get overwritten. This error can only be found by code inspection. coap_encode_var_safe(buf, sizeof(buf), 0xfff); would catch this error at run-time and should be used instead.

Definition at line 115 of file encode.h.

+ Here is the call graph for this function:

◆ coap_fls()

int coap_fls ( unsigned int  i)

Definition at line 15 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_flsll()

int coap_flsll ( long long  i)

Definition at line 21 of file encode.c.

+ Here is the caller graph for this function: