Android application to manipulate sd image from the site
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaaa |
h0bby1 (2567) 480 posts |
aaa |
Ronald May (387) 407 posts |
I missed these latest posts because of the new page, yes the answer was to emphaticly set the terminating 0. FYII always get a compiler warning: squach.c:140: warning: useless storage class specifier in empty declaration |
Rick Murray (539) 13850 posts |
Not strncpy_s ? |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaa |
Ronald May (387) 407 posts |
line 140: }; Regarding the strncpy, I will have to make a simple test case and forward it as a bug, It could be giving problems. I have had problems with argument handling on one occasion, could be a reason. Any bugfix is obviously a good thing. |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaa |
Ronald May (387) 407 posts |
The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated. Ah, I see now, it is not a bug, I guess the purpose of strncpy is to at least allow you to restrict the amount from a large buffer to fit in a smaller buffer. |
h0bby1 (2567) 480 posts |
aaaa |
Ronald May (387) 407 posts |
The string concept is there in BASIC, I had given up on that in C, You could keep improving/making your own functions, but they will get bigger. A lot of source code has wrapper functions around the basic functions, nearly always have their own error functions. I see your point though, I will look at the memcpy function more in the future. |
h0bby1 (2567) 480 posts |
aaaaa |
h0bby1 (2567) 480 posts |
aaaa |
Ronald May (387) 407 posts |
Like this you can know the length of the string without having to parse it for an hypothetical null terminating character that can be removed by smart functions like strncpy. Yeh, I like the idea of keeping things simple with one function like memcpy though. |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaaa |
h0bby1 (2567) 480 posts |
aaa |
Rick Murray (539) 13850 posts |
Exactly. There is a lot of stuff in the standard C library definition (one might even say C itself) that appears to take the path of least |
Rick Murray (539) 13850 posts |
Use calloc() instead of malloc()? |
Ronald May (387) 407 posts |
I updated it again, now it can browse directories and output squashed file from the sqar file. I compiled this on linux tonight, a few new warnings, and squached a file there and back no problems. However I didn’t get the sqar back to anything using squach, was the output.Edit: now I’m getting the directory contents like this:
The (linux) gcc warnings are
I’m not trying to push you, have a rest now and again!, just for your information. I’ll have another go with RISC OS in the morning |
h0bby1 (2567) 480 posts |
aaaa |
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15