home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,030 of 2,978   
   Robert AH Prins to All   
   Re: Mismatched Array Sizes   
   28 Jan 06 18:14:46   
   
   From: prino@onetel.com   
      
    wrote in message   
   news:1138470566.136668.295040@z14g2000cwz.googlegroups.com...   
   >I am maintaining some legacy code (PASCAL 7) and I have run across a   
   > piece of code I question and am not sure how it is working and not   
   > crashing. There are two arrays that are created (e.g., doubles, w/2000   
   > elements) and a function that can act these arrays (e.g.,   
   > VEC_Add(resultant_array, array1, array2, num_of_elements)). But the   
   > function is passed a num_of_elements that is much greater than the   
   > actual number of elements in the array1 or 2. This function is nothing   
   > more than a loop that adds each element of one to the corresponding   
   > element of the other. However, the loop variable is much more than the   
   > array sizes so:   
   >   
   > 1) where is it getting the data to "add" once it exceeds array1 & 2   
   > length?   
      
   From whatever is located in memory after the arrays.   
      
   > 2) won't this just contain garbage? AND   
      
   It contains bits that are treated as bytes, integers, words or whatever   
   the arrays contain.   
      
   > 3) since the initialized resultant array's length is the same as   
   > array1   
   > or 2's, won't the resultant array be overwriting possibly something   
   > important?   
      
   Not possibly, certainly.   
      
   Compile the program with range checking on {$R+} and see what's   
   happening.   
      
   Robert   
   --   
   Robert AH Prins   
   prino at prino dot plus dot com   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca