i was asking this person nicknamed incubus for help in msn... wonder if he'll ever get back to me on it. in time.
| 8:50:54 PM | ok a little background to this... the program was written in C, we had to get it debugged, compiled and running. then we have to convert to C++. - have to use new/delete instead of malloc/free. - use inline functions instead of #define - use iostream/fstream instead of stdio |
| 8:51:41 PM | the program is suppose to merge 2 16bit wave files together |
| 8:52:06 PM | i've got a struct with a short* member called "channel" that stores the actual data (apart from the header info) |
| 8:54:04 PM | there's this function that allocates memory for the channel to which i'm using (not sure if it's correct) short* s = new short(NSAMPLE(w ) * BALIGN(w )); CHANNEL(w, s); where NSAMPLE and BALIGN returns int values of the other members in that struct |
| 8:56:39 PM | let's take it that the input files to be merged are fileA and fileB, where the output will be fileX there will be this memcpy after the memory allocation is done memcpy((void*)&(fileX)->channel, (void*)&(fileA)->channel, (NSAMPLE(fileA)*BALIGN(fileA))); the same goes for fileB. |
| 8:58:08 PM | so basically i'm getting segmentation fault for this memcpy, and after testing it seems the max the memcpy function can copy into fileX is 2816bytes. the seg fault shows at 2817bytes and onwards |
| 8:59:18 PM | and i realised the short* s = new short[whatever_number]; gives the same problem as with short* s = new short; |
| 9:04:22 PM | the short* channel member is access by inline short* CHANNEL(const WAVE* w) return (w )->channel; i'm not sure if this is related but the mutator(set method) is inline void CHANNEL(WAVE* w, short* x) (w )->channel = x; |
No comments:
Post a Comment