mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 04:50:17 +00:00
Update safestl.h
This commit is contained in:
parent
ac332d8122
commit
07f8c6fc06
@ -77,9 +77,7 @@ namespace pkpy {
|
|||||||
|
|
||||||
ArgList(const ArgList& other){
|
ArgList(const ArgList& other){
|
||||||
__tryAlloc(other._size);
|
__tryAlloc(other._size);
|
||||||
for(uint8_t i=0; i<_size; i++){
|
for(uint8_t i=0; i<_size; i++) _args[i] = other._args[i];
|
||||||
_args[i] = other._args[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArgList(ArgList&& other) noexcept {
|
ArgList(ArgList&& other) noexcept {
|
||||||
@ -112,24 +110,11 @@ namespace pkpy {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t size() const {
|
inline uint8_t size() const { return _size; }
|
||||||
return _size;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArgList subList(uint8_t start) const {
|
|
||||||
if(start >= _size) return ArgList(0);
|
|
||||||
ArgList ret(_size - start);
|
|
||||||
for(uint8_t i=start; i<_size; i++){
|
|
||||||
ret[i-start] = _args[i];
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyVarList toList() const {
|
PyVarList toList() const {
|
||||||
PyVarList ret(_size);
|
PyVarList ret(_size);
|
||||||
for(uint8_t i=0; i<_size; i++){
|
for(uint8_t i=0; i<_size; i++) ret[i] = _args[i];
|
||||||
ret[i] = _args[i];
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,12 +124,10 @@ namespace pkpy {
|
|||||||
uint8_t old_size = _size;
|
uint8_t old_size = _size;
|
||||||
__tryAlloc(old_size+1);
|
__tryAlloc(old_size+1);
|
||||||
_args[0] = self;
|
_args[0] = self;
|
||||||
|
|
||||||
if(old_size == 0) return;
|
if(old_size == 0) return;
|
||||||
|
|
||||||
memcpy(_args+1, old_args, sizeof(PyVar)*old_size);
|
memcpy(_args+1, old_args, sizeof(PyVar)*old_size);
|
||||||
memset(old_args, 0, sizeof(PyVar)*old_size);
|
memset(old_args, 0, sizeof(PyVar)*old_size);
|
||||||
|
|
||||||
if(old_size >= MAX_POOLING_N || _poolArgList[old_size].size() > 32){
|
if(old_size >= MAX_POOLING_N || _poolArgList[old_size].size() > 32){
|
||||||
delete[] old_args;
|
delete[] old_args;
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user