-
-
Save abrarShariar/36d1d633f1633b1a047d to your computer and use it in GitHub Desktop.
#include "spv.h" | |
void main(){ | |
SPV test; | |
SPVconstruct(3,&test); //this shows 3 garbage values | |
//SPVconstruct(0,&test); //this works fine | |
int i; | |
for(i=0;i<3;i++){ | |
SPVpush_back(&test,999); | |
//SPVpush_front(&test,999); | |
} | |
SPVprint(&test); //prints some garbage values | |
} |
Output is 0 0 0 999 999 999 for me.
Seems to be working fine.
By the way, zero initialization is left to to compiler/user.
Maybe your compiler is not zero initializing it?
Output: 3941640 3936056 1684234849 999 999 999
when SPVconstruct(3,&test);
Output: 999 999 999
when SPVconstruct(0,&test);
Works fine when:
SPVconstruct(0,&test);
SPVinsert() is used
But getting garbage when
SPVconstruct(any_size,&test);
SPVinsert() is used
Number of garbage values is varying according to the size passed in SFVconstruct()
Found problem and fixed, my compiler GCC zero initializes malloc by default, but your compiler MingW does not. Now I've updated it to manually zero initialize by default and added another Constructor without zero initialization.
Check it now and let me know.
Added zero initialization and a simple optimization in case compiler already did it.
Thanks a lot for finding this bug.
It is working fine
Zero padded
Getting some garbage values running this code, am I missing something ??
To be specific - it shows garbage values depending on the size in SPVconstruct()