www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/07/29/19:57:24

Date: Thu, 29 Jul 1993 17:30:53 -0600
From: "John M. Weiss" <jweiss AT silver DOT sdsmt DOT edu>
To: neek AT cerecam DOT uct DOT ac DOT za
Subject: dynamic 2-D arrays
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

On 28 Jul 93 Nick van der Merwe <NEEK AT cerecam DOT uct DOT ac DOT za> wrote:

> I have an image processing program that is crashing at a specific
> point with the error message :
>
> " Segmentation violation in pointer 0x00000000
>  at 40:465c
>  Exception 14 (0xe) at eip=465c"
>
> Previously I had 3 2D arrays define straight i.e image[512][512] etc
> , and my program worked fine. The total data space needed was far
> less than the 8M I have on board.
>
> When I changed my 2D arrays to **image etc. and dynamically allocated
> and freed the arrays as needed , my program crashed with the error
> message. Note that the 2D arrays were working as I did convolutions
> etc. on them before the crash. The program crashed right at the end
> of a search through one of these 2D arrays.
>
> Can anyone make any sense out of this?Why is it crashing with dynamic
> allocation but not with straight allocation of 2D arrays?How can I
> find out exactly what is causing the problem?

It really sounds as if you have a pointer gone astray. Your best approach
is to try and localize the problem. This can be accomplished by printing
debugging statements to find out where the program crashes, and what
your array indices were at the time. (Or step through the code with a
debugger.)

How are you allocating the arrays? I recently uploaded ALLOC2D.ZIP to
omnigate. ALLOC2D.ZIP contains the dynamic 2-D array allocation code
that I have been using successfully for years in my image processing
programs. If you are already using my routines, I will be glad to look
at your code to see if I can spot the problem.

				- JW

Dr. John M. Weiss, Associate Professor
Department of Mathematics and Computer Science
South Dakota School of Mines and Technology
501 East St. Joseph Street
Rapid City, SD 57701-3995
605-394-6145    jweiss AT silver DOT sdsmt DOT edu


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019