Hi all.
I am currently trying to debug some C library code I'm writing for serial port access (on Posix). I'm getting some strange segfaults though.
Does anybody know what I might be doing wrong with this line?
I've managed to isolate this line using stractegically placed printf() statements (if anyone has a better debugging technique I'd like to hear it!)Code:szNewBuffer = (char *)calloc(iBufferLen - iLineLen + 1, 1);
the expressoin (iBufferLen - iLineLen + 1) evaluates to various numbers depending on the circumstances, but as an example, prior to one particular segfault I've encountered it was 25. So it's not negative or anything silly like that. In this case I'm trying to allocate space for a string of 24 characters.
Any ideas?




Reply With Quote