Is it possible to reset arrays & pointers......?

Hi.

I'm using large arrays with pointers.

Now I'm getting the message of to large array in

my programme , and I'm ""told"" to use "FAR".

I wonder is it possible to "reset" the pointers

and arrays "in" the programme, and use them

again to do "other" calculations.

In that way I'm thinking of "saving...?" memory.

Is it possible or complelely wrong...?


I'm in the need of very large arrays with "very fast"

calculations.


Thanks in advance.

peter


Comments

  • : I'm using large arrays with pointers.

    : Now I'm getting the message of to large array in

    : my programme , and I'm ""told"" to use "FAR".

    : I wonder is it possible to "reset" the pointers

    : and arrays "in" the programme, and use them

    : again to do "other" calculations.

    : In that way I'm thinking of "saving...?" memory.

    : Is it possible or complelely wrong...?


    You can always assign anything you want to an array. You CAN, as an example, create an array in your main() routine, pass it (by pointer) to all your functions, and fill it in with different data in each function. As long as your aware that each function must initialize the array each time it is called in this scenario. This may or may not be a good approach, depending on the details of the program, but you get the idea.

    It sounds like your array is too large though (you must in a 16 bit world :) ). If your creating the array on the stack, get rid of it and allocate it dynamically (with malloc, farmalloc, ..). If indeed you are in a 16bit environment, then you are pretty much limited to arrays of 64K in size. Supposedly you can use the huge memory model to fix this, but way back when I had a similar problem, I couldn't get that to work either. (I quickly just jumped into the 32bit world).

    Creating far arrays will allow you to access more memory, but still pretty much limited to 64K for each array.


    One more note, just because it scares me to hear you say reset pointers and arrays. I'm probably misinterpreting you here, but just in case I'll mention this anyway. You can set a pointer to point to anything, anytime. Arrays, which although they are pointers to memory, can't (should never) be set to point to anything else. If it is a stack array, don't ever reassign the pointer. If it is a dynamic array, don't reassign the pointer until you free the memory first.


    Rock





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories