buddyLV,
Unfortunately, there is no ANSI C or CVI function which will do this automatically. However, you should be able to implement this yourself. At a high level, you should be able to do the following (assuming that the size of data you are interested in is always smaller than your page size):
- Allocate enough memory to guarantee that your data can fit onto one page. In worst case, a standard allocation would contain all but the last byte on the first page of memory. As a result, you would have dataSize-1 bytes on the first page, but still need dataSize bytes worth of memory on the second page. Allocating 2*dataSize - 1 bytes of memory will guarantee that all of your data will be able to fit on either the first or second page.
- Using the first address of memory that you allocated, compute the first address of the next page of memory.
- Using the first address of your allocation and the first address of the next page, determine if your data should be placed at the first address of allocation or the first address of the next page.
- Use the address determined in step 3 for storing and accessing your data, and use the first address of the allocation when you eventually free the memory.
I have found the following discussions on the topic which may be helpful for you as you impmlement this:
http://bytes.com/topic/c/answers/216430-alligned-memory-allocationhttp://stackoverflow.com/questions/227897/solve-the-memory-alignment-in-c-interview-question-that-st...
- John
National Instruments
Applications Engineer