updated file io test to avoid crash

This commit is contained in:
2025-10-03 20:34:49 -04:00
parent 47a2ee98b4
commit fcbb1d2941
18 changed files with 2255 additions and 9 deletions
Binary file not shown.
+1 -1
View File
@@ -17,7 +17,7 @@ builddir = "./build_linux64"
doinstall = True #copies the build_output to the install dir when finished
cc = "g++" #compiler
cflags = "-fPIC"
libraries = "-l{}".format(libname)
libraries = "-l{} -lpthread".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
linkerflags = "-static -static-libgcc -Wl,-rpath=."
srcexts = [".c",".cpp"]
+1 -1
View File
@@ -17,7 +17,7 @@ builddir = "./build_linux64"
doinstall = True #copies the build_output to the install dir when finished
cc = "g++" #compiler
cflags = "-fPIC"
libraries = "-l{}".format(libname)
libraries = "-l{} -lpthread".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
linkerflags = "-static -static-libgcc -Wl,-rpath=."
srcexts = [".c",".cpp"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+14 -6
View File
@@ -133,7 +133,7 @@ namespace ams
{
int ret = amsstring_success;
ams_chartype *newcstring = NULL;
int I;
int I = 0;
_newlen = (_newlen<0) ? 0 : _newlen;
@@ -145,6 +145,10 @@ namespace ams
return ret;
}
for(I=0;I<(_newlen+1);I++) //init entire string to '\0' - slower, but valgrind complains less
{
newcstring[I] = (ams_chartype) '\0';
}
if(cstring!=NULL)
{
for(I=0;I<(_newlen+1) && I<(length+1);I++)
@@ -152,10 +156,10 @@ namespace ams
newcstring[I] = cstring[I];
}
}
for(I=length;I<(_newlen+1);I++)
{
newcstring[I] = (ams_chartype) '\0';
}
// for(I=length;I<(_newlen+1);I++) //init only new portion of string to '\0' - valgrind complains?
// {
// newcstring[I] = (ams_chartype) '\0';
// }
newcstring[_newlen] = '\0';
@@ -1402,7 +1406,11 @@ namespace ams
{
const int BUFFSZ = 8000;
char buff[BUFFSZ];
int N;
int N = 0;
int I = 0;
for(I=0;I<BUFFSZ;I++) buff[I] = '\0'; //this shuts valgrind up about uniitialized values
if(fp!=NULL && s!=NULL)
{
if(!feof(fp))
+6
View File
@@ -430,6 +430,12 @@ namespace ams
fp = fopen("./ref/0p375_hexbolt.scad","r");
fp2 = fopen("./ref/testrewrite.scad","w+");
if(fp==NULL || fp2==NULL)
{
printf("amsstring4_test_freadwrite: could not open test files, make sure you're executing this from the project root.\n");
return;
}
I = 0;
while(!feof(fp))
{
+1 -1
View File
@@ -20,7 +20,7 @@ int main(int argc, char* argv[])
amsstring4_test_strip();
amsstring4_test_freadwrite();
amsstring4_test_concatenation_operators();
amsstring4_test_concatenation_operators(); //segfault on Debian11?
return ret;
}