Skip to content

Commit 9cbf4cb

Browse files
lbernstoneme-no-dev
authored andcommitted
Modified WString.h to allow for larger strings with PSRAM
1 parent ed4d0cd commit 9cbf4cb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cores/esp32/WString.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ class String {
281281
// Contains the string info when we're not in SSO mode
282282
struct _ptr {
283283
char * buff;
284-
uint16_t cap;
285-
uint16_t len;
284+
uint32_t cap;
285+
uint32_t len;
286286
};
287287
// This allows strings up up to 11 (10 + \0 termination) without any extra space.
288288
enum { SSOSIZE = sizeof(struct _ptr) + 4 - 1 }; // Characters to allocate space for SSO, must be 12 or more
@@ -291,7 +291,11 @@ class String {
291291
unsigned char len : 7; // Ensure only one byte is allocated by GCC for the bitfields
292292
unsigned char isSSO : 1;
293293
} __attribute__((packed)); // Ensure that GCC doesn't expand the flag byte to a 32-bit word for alignment issues
294-
enum { CAPACITY_MAX = 65535 }; // If typeof(cap) changed from uint16_t, be sure to update this enum to the max value storable in the type
294+
#ifdef BOARD_HAS_PSRAM
295+
enum { CAPACITY_MAX = 3145728 };
296+
#else
297+
enum { CAPACITY_MAX = 65535 };
298+
#endif
295299
union {
296300
struct _ptr ptr;
297301
struct _sso sso;

0 commit comments

Comments
 (0)