Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of WIZnet_Library by
pico_string.h
00001 // pico_string.h 2013/8/27 00002 #pragma once 00003 class pico_string { 00004 public: 00005 pico_string(){ 00006 _len = 0; 00007 _buf = (char*)malloc(1); 00008 if (_buf) { 00009 _buf[0] = '\0'; 00010 } 00011 } 00012 ~pico_string() { 00013 if (_buf) { 00014 free(_buf); 00015 } 00016 } 00017 bool empty() { 00018 return _len == 0; 00019 } 00020 void append(const char* s, int len) { 00021 if (_buf == NULL) { 00022 return; 00023 } 00024 char* p = (char*)malloc(_len+len+1); 00025 if (p == NULL) { 00026 return; 00027 } 00028 memcpy(p, _buf, _len); 00029 memcpy(p+_len, s, len); 00030 p[_len+len] = '\0'; 00031 free(_buf); 00032 _buf = p; 00033 } 00034 void append(const char* s) { 00035 append(s, strlen(s)); 00036 } 00037 char* c_str() { 00038 if (_buf) { 00039 return _buf; 00040 } 00041 return ""; 00042 } 00043 private: 00044 char* _buf; 00045 int _len; 00046 };
Generated on Thu Jul 14 2022 08:03:44 by
