Added bytes alignment calculation on ESP8266

This commit is contained in:
Charles 2016-05-09 16:07:38 +02:00
parent 61d36940d9
commit 976095f3ef
2 changed files with 10 additions and 4 deletions

View File

@ -249,10 +249,10 @@ ValueList * TInfo::valueAdd(char * name, char * value, uint8_t checksum, uint8_t
// + Value + '\0'
size_t size ;
#ifdef ESP8266
lgname = xPortWantedSizeAlign(lgname+1); // Align name buffer
lgvalue = xPortWantedSizeAlign(lgvalue+1); // Align value buffer
lgname = ESP8266_allocAlign(lgname+1); // Align name buffer
lgvalue = ESP8266_allocAlign(lgvalue+1); // Align value buffer
// Align the whole structure
size = xPortWantedSizeAlign( sizeof(ValueList) + lgname + lgvalue ) ;
size = ESP8266_allocAlign( sizeof(ValueList) + lgname + lgvalue ) ;
#else
size = sizeof(ValueList) + lgname + 1 + lgvalue + 1 ;
#endif

View File

@ -38,10 +38,10 @@
// Using ESP8266 ?
#ifdef ESP8266
//#include "stdlib_noniso.h"
#include <ESP8266WiFi.h>
#endif
// Define this if you want library to be verbose
//#define TI_DEBUG
@ -67,6 +67,12 @@
#define TI_Debugflush
#endif
#ifdef ESP8266
// For 4 bytes Aligment boundaries
#define ESP8266_allocAlign(size) ((size + 3) & ~((size_t) 3))
#endif
#pragma pack(push) // push current alignment to stack
#pragma pack(1) // set alignment to 1 byte boundary