Skip to content

Commit

Permalink
Added bytes alignment calculation on ESP8266
Browse files Browse the repository at this point in the history
  • Loading branch information
hallard committed May 9, 2016
1 parent 61d3694 commit 976095f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/LibTeleinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/LibTeleinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 976095f

Please sign in to comment.