toasty
05-19-2003, 10:40 AM
Just a small question about the vector function given in nrutil.c on page 943 of NRC, second edition.
What is the purpose of NR_END? Memory for nh-nl+1+1 is allocated, while a vector which starts at nl and ends at nh uses nh-nl+1 cells. It seems to me that 1 more element is being allocated than necessary.
I have had times however, when having a program which crashes under weird circumstances, with such malloc/calloc routines, that sometimes making the vectors a bit bigger (sometimes by 1) alleviates the crashing problem (probably because of a bug somewhere I was unable to find), I don't suppose that this is the reason you are doing it here?
What is the purpose of NR_END? Memory for nh-nl+1+1 is allocated, while a vector which starts at nl and ends at nh uses nh-nl+1 cells. It seems to me that 1 more element is being allocated than necessary.
I have had times however, when having a program which crashes under weird circumstances, with such malloc/calloc routines, that sometimes making the vectors a bit bigger (sometimes by 1) alleviates the crashing problem (probably because of a bug somewhere I was unable to find), I don't suppose that this is the reason you are doing it here?