Link to home
Start Free TrialLog in
Avatar of lsjun
lsjun

asked on

[q]memory problem

What is a problem of below code..?
When I executed(or only allocate the memory block) by using for loop about 20 times, I met a General Protection Error..( in about 15 times loop, GPE is not shown.)
(x,ypts is an integer about 128-512)
void AllocateMemory (const int id)
{
      int       i;

      if (Matrix[id] != NULL) return;
      if (( id >= 0 ) && ( id < 128 ))
                 {
          Matrix[id] = ( int far * far * ) GlobalAllocPtr ( GHND, ActiveChildInfo.ypts * sizeof(int far *) );

         for ( i = 0; i < ActiveChildInfo.ypts; i++ )
            Matrix[id][i] = ( int far * ) GlobalAllocPtr ( GHND, ActiveChildInfo.xpts * sizeof(int) );
      }
ASKER CERTIFIED SOLUTION
Avatar of alexo
alexo
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you're writing for Win32, use HeapAlloc() or even malloc() or new.