mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
zero init struct
This commit is contained in:
parent
f837ace29c
commit
66423f08a8
@ -93,16 +93,17 @@ struct C99Struct{
|
|||||||
char* p;
|
char* p;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
C99Struct(int new_size){
|
C99Struct(int new_size, bool zero_init){
|
||||||
this->size = new_size;
|
this->size = new_size;
|
||||||
if(size <= INLINE_SIZE){
|
if(size <= INLINE_SIZE){
|
||||||
p = _inlined;
|
p = _inlined;
|
||||||
}else{
|
}else{
|
||||||
p = (char*)malloc(size);
|
p = (char*)malloc(size);
|
||||||
}
|
}
|
||||||
|
if(zero_init) memset(p, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
C99Struct(void* p, int size): C99Struct(size){
|
C99Struct(void* p, int size): C99Struct(size, false){
|
||||||
if(p != nullptr) memcpy(this->p, p, size);
|
if(p != nullptr) memcpy(this->p, p, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user