Fork of original library, increased Tx buffer to 16kB

Dependents:   W5500-SNTPClient-example

Committer:
star297
Date:
Thu May 02 20:47:25 2019 +0000
Revision:
0:e9275bdfa393
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
star297 0:e9275bdfa393 1 // pico_string.h 2013/8/27
star297 0:e9275bdfa393 2 #pragma once
star297 0:e9275bdfa393 3 class pico_string {
star297 0:e9275bdfa393 4 public:
star297 0:e9275bdfa393 5 pico_string(){
star297 0:e9275bdfa393 6 _len = 0;
star297 0:e9275bdfa393 7 _buf = (char*)malloc(1);
star297 0:e9275bdfa393 8 if (_buf) {
star297 0:e9275bdfa393 9 _buf[0] = '\0';
star297 0:e9275bdfa393 10 }
star297 0:e9275bdfa393 11 }
star297 0:e9275bdfa393 12 ~pico_string() {
star297 0:e9275bdfa393 13 if (_buf) {
star297 0:e9275bdfa393 14 free(_buf);
star297 0:e9275bdfa393 15 }
star297 0:e9275bdfa393 16 }
star297 0:e9275bdfa393 17 bool empty() {
star297 0:e9275bdfa393 18 return _len == 0;
star297 0:e9275bdfa393 19 }
star297 0:e9275bdfa393 20 void append(const char* s, int len) {
star297 0:e9275bdfa393 21 if (_buf == NULL) {
star297 0:e9275bdfa393 22 return;
star297 0:e9275bdfa393 23 }
star297 0:e9275bdfa393 24 char* p = (char*)malloc(_len+len+1);
star297 0:e9275bdfa393 25 if (p == NULL) {
star297 0:e9275bdfa393 26 return;
star297 0:e9275bdfa393 27 }
star297 0:e9275bdfa393 28 memcpy(p, _buf, _len);
star297 0:e9275bdfa393 29 memcpy(p+_len, s, len);
star297 0:e9275bdfa393 30 p[_len+len] = '\0';
star297 0:e9275bdfa393 31 free(_buf);
star297 0:e9275bdfa393 32 _buf = p;
star297 0:e9275bdfa393 33 }
star297 0:e9275bdfa393 34 void append(const char* s) {
star297 0:e9275bdfa393 35 append(s, strlen(s));
star297 0:e9275bdfa393 36 }
star297 0:e9275bdfa393 37 char* c_str() {
star297 0:e9275bdfa393 38 if (_buf) {
star297 0:e9275bdfa393 39 return _buf;
star297 0:e9275bdfa393 40 }
star297 0:e9275bdfa393 41 return "";
star297 0:e9275bdfa393 42 }
star297 0:e9275bdfa393 43 private:
star297 0:e9275bdfa393 44 char* _buf;
star297 0:e9275bdfa393 45 int _len;
star297 0:e9275bdfa393 46 };