mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
some fix
This commit is contained in:
parent
f3148ac206
commit
e7aababa36
@ -23,7 +23,7 @@ int utf8len(unsigned char c, bool suppress){
|
||||
if(this->size < (int)sizeof(this->_inlined)){ \
|
||||
this->data = this->_inlined; \
|
||||
}else{ \
|
||||
this->data = (char*)pool128_alloc(this->size+1); \
|
||||
this->data = (char*)std::malloc(this->size+1); \
|
||||
}
|
||||
|
||||
#define PK_STR_COPY_INIT(__s) \
|
||||
@ -103,7 +103,7 @@ int utf8len(unsigned char c, bool suppress){
|
||||
}
|
||||
|
||||
Str& Str::operator=(const Str& other){
|
||||
if(!is_inlined()) pool128_dealloc(data);
|
||||
if(!is_inlined()) std::free(data);
|
||||
size = other.size;
|
||||
is_ascii = other.is_ascii;
|
||||
PK_STR_ALLOCATE()
|
||||
@ -174,7 +174,7 @@ int utf8len(unsigned char c, bool suppress){
|
||||
}
|
||||
|
||||
Str::~Str(){
|
||||
if(!is_inlined()) pool128_dealloc(data);
|
||||
if(!is_inlined()) std::free(data);
|
||||
}
|
||||
|
||||
Str Str::substr(int start, int len) const {
|
||||
@ -410,14 +410,10 @@ int utf8len(unsigned char c, bool suppress){
|
||||
}
|
||||
|
||||
Str SStream::str(){
|
||||
#if 0
|
||||
// after this call, the buffer is no longer valid
|
||||
buffer.reserve(buffer.size() + 1); // allocate one more byte for '\0'
|
||||
buffer[buffer.size()] = '\0'; // set '\0'
|
||||
return Str(buffer.detach());
|
||||
#else
|
||||
return Str(buffer.data(), buffer.size());
|
||||
#endif
|
||||
}
|
||||
|
||||
SStream& SStream::operator<<(const Str& s){
|
||||
|
@ -1396,7 +1396,7 @@ __EAT_DOTS_END:
|
||||
|
||||
Str TokenDeserializer::read_string_from_hex(char c){
|
||||
std::string_view s = read_string(c);
|
||||
char* buffer = (char*)pool128_alloc(s.size()/2 + 1);
|
||||
char* buffer = (char*)std::malloc(s.size()/2 + 1);
|
||||
for(int i=0; i<s.size(); i+=2){
|
||||
char c = 0;
|
||||
if(s[i]>='0' && s[i]<='9') c += s[i]-'0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user