whatever is in the buffer? No, don't free() or you will lose it. Copy it to a local var and then free(). Then try a malloc(). If you still don't have enough then your compiler is set to a to-low value of local space. Try to get more from a shared segment. If that doesn't work then ABEND because you have other, more serious, problems.
What we used to have to do, in the old days, is calculate the max worst case memory usage and predeclare that in the compiler's switches [I'm talking Lattice C v3.2, under IBM PC-DOS, circa 1987 here]. This day and age, you shouldn't have to do that. Somehow, your executable doesn't have enough allocatable RAM and the OS isn't giving you any more.
Generally, if realloc() doesn't work then it's about to crash anyway. |