actube/src/cw/bstr16_create.c
7u83@mail.ru d8c8bd022e Work on ansi and clean Makefiles
FossilOrigin-Name: 0805f78d34219a2aac597a313081ce869c389e6b5d471c65c7f43d0906c0a400
2018-02-28 08:05:45 +00:00

14 lines
218 B
C

#include "bstr.h"
uint8_t * bstr16_create(const uint8_t *data, uint16_t len)
{
uint8_t * str = malloc(2+len*sizeof(uint8_t));
if (!str)
return 0;
*((uint16_t*)str)=len;
memcpy(str+2,data,len);
return str;
}