Skip to content

Commit d996a84

Browse files
committed
Add support for ESP8266
1 parent 8bd4dfb commit d996a84

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

EfficientString/LoggingProxies.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ inline void strncpy(char *dst, const char *src, size_t n) {
5454
min(::strlen(src), n));
5555
}
5656

57+
#ifndef strcpy_P
5758
inline void strcpy_P(char *dst, const char *src) {
5859
::strcpy_P(dst, src);
5960
log(F("- strcpy_P(%p, %p) - %u bytes"), dst, src, ::strlen_P(src));
6061
}
62+
#endif
63+
64+
inline void strncpy_P(char *dst, const char *src, size_t n) {
65+
::strncpy_P(dst, src, n);
66+
log(F("- strncpy_P(%p, %p, %u) - %u bytes"), dst, src, n,
67+
min(::strlen(src), n));
68+
}
6169
} // namespace cpp4arduino

EfficientString/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ The modified class is in a different namespace, to avoid the name clash.
1717
Results
1818
-------
1919

20+
## On AVR
21+
2022
Here is the serial output of this program with the Arduino Core for AVR version 1.6.22:
2123

2224
```
@@ -110,4 +112,101 @@ Here is the serial output of this program with the Arduino Core for AVR version
110112
- malloc(33) -> 0x23c
111113
- strcpy(0x23c, 0x16e) - 32 bytes
112114
- free(0x23c)
115+
```
116+
117+
## On ESP8266
118+
119+
Here is the serial output of this program with the Arduino Core for ESP8266 version 2.4.2:
120+
121+
```
122+
#1: Initialize from RAM
123+
- malloc(8) -> 0x3ffef3fc
124+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
125+
- free(0x3ffef3fc)
126+
127+
#2: Initialize from Flash
128+
- malloc(8) -> 0x3ffef3fc
129+
- strncpy_P(0x3ffef3fc, 0x40235704, 2147483647) - 7 bytes
130+
- free(0x3ffef3fc)
131+
132+
#3: toCharArray()
133+
- malloc(8) -> 0x3ffef3fc
134+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
135+
- strncpy(0x3fffff70, 0x3ffef3fc, 7) - 7 bytes
136+
- free(0x3ffef3fc)
137+
138+
#4: c_str()
139+
- malloc(8) -> 0x3ffef3fc
140+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
141+
- free(0x3ffef3fc)
142+
143+
#5: Pass by value
144+
- malloc(8) -> 0x3ffef3fc
145+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
146+
- malloc(8) -> 0x3ffef40c
147+
- strcpy(0x3ffef40c, 0x3ffef3fc) - 7 bytes
148+
- free(0x3ffef40c)
149+
- free(0x3ffef3fc)
150+
151+
#6: Pass by const reference
152+
- malloc(8) -> 0x3ffef3fc
153+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
154+
- free(0x3ffef3fc)
155+
156+
#7: Move instance
157+
- malloc(8) -> 0x3ffef3fc
158+
- strcpy(0x3ffef3fc, 0x3ffe8878) - 7 bytes
159+
- free(0x3ffef3fc)
160+
- free(0)
161+
162+
#8: Append temporaries
163+
- malloc(6) -> 0x3ffef3fc
164+
- strcpy(0x3ffef3fc, 0x3ffe889c) - 5 bytes
165+
- malloc(6) -> 0x3ffef40c
166+
- strcpy(0x3ffef40c, 0x3ffef3fc) - 5 bytes
167+
- realloc(0x3ffef40c, 18) -> 0x3ffef40c
168+
- strcpy(0x3ffef411, 0x3ffe88a4) - 12 bytes
169+
- realloc(0x3ffef40c, 23) -> 0x3ffef40c
170+
- strcpy(0x3ffef41d, 0x3ffe88b4) - 5 bytes
171+
- realloc(0x3ffef40c, 33) -> 0x3ffef40c
172+
- strcpy(0x3ffef422, 0x3ffe88bc) - 10 bytes
173+
- malloc(33) -> 0x3ffef434
174+
- strcpy(0x3ffef434, 0x3ffef40c) - 32 bytes
175+
- free(0x3ffef40c)
176+
- free(0x3ffef3fc)
177+
- free(0x3ffef434)
178+
179+
#9: Mutate instance
180+
- malloc(6) -> 0x3ffef3fc
181+
- strcpy(0x3ffef3fc, 0x3ffe889c) - 5 bytes
182+
- realloc(0x3ffef3fc, 18) -> 0x3ffef3fc
183+
- strcpy(0x3ffef401, 0x3ffe88a4) - 12 bytes
184+
- realloc(0x3ffef3fc, 23) -> 0x3ffef3fc
185+
- strcpy(0x3ffef40d, 0x3ffe88b4) - 5 bytes
186+
- realloc(0x3ffef3fc, 33) -> 0x3ffef3fc
187+
- strcpy(0x3ffef412, 0x3ffe88bc) - 10 bytes
188+
- free(0x3ffef3fc)
189+
190+
#10: Call reserve
191+
- malloc(1) -> 0x3ffef3fc
192+
- strcpy(0x3ffef3fc, 0x3ffe88e8) - 0 bytes
193+
- realloc(0x3ffef3fc, 65) -> 0x3ffef3fc
194+
- strcpy(0x3ffef3fc, 0x3ffe889c) - 5 bytes
195+
- strcpy(0x3ffef401, 0x3ffe88a4) - 12 bytes
196+
- strcpy(0x3ffef40d, 0x3ffe88b4) - 5 bytes
197+
- strcpy(0x3ffef412, 0x3ffe88bc) - 10 bytes
198+
- free(0x3ffef3fc)
199+
200+
#11: Pass a null string to the constructor
201+
- malloc(65) -> 0x3ffef3fc
202+
- strcpy(0x3ffef3fc, 0x3ffe889c) - 5 bytes
203+
- strcpy(0x3ffef401, 0x3ffe88a4) - 12 bytes
204+
- strcpy(0x3ffef40d, 0x3ffe88b4) - 5 bytes
205+
- strcpy(0x3ffef412, 0x3ffe88bc) - 10 bytes
206+
- free(0x3ffef3fc)
207+
208+
#12: Concat at compile time
209+
- malloc(33) -> 0x3ffef3fc
210+
- strcpy(0x3ffef3fc, 0x3ffe88c8) - 32 bytes
211+
- free(0x3ffef3fc)
113212
```

0 commit comments

Comments
 (0)