Destined Soul
May 29th, 2002, 11:44 AM
Hi all.
I've been having a little trouble with a dll, written in C++, interfacing with VB. Well, it's not the interfacing with VB that's the problem, but rather some strange memory errors occuring.
Oh, for the record, I'm using Visual Studio 6, SP5 on Win2000 Pro.
If any of you folks are familiar with the Hough transform, or variants of it, this might make more sense, but the idea should be seen from anyone. In this dll function, I am passed an array, and create my own 2d "matrix" to copy/edit/paste the data that was sent. What I'm wondering is if the following syntax is correct:
myFunc(byte* data, short width, short height)
{
int** array;
int i, j;
array = new int* [width];
for (i = 0; i < width; i++)
array[i] = new int [height];
...
for (i = 0; i < width; i++)
delete array[i];
delete array;
}I'm wondering if there's anything wrong with this syntax, other than checking to see if any of the values are NULL.
I'm asking this mainly because I was getting the weird errorDebug Error!
Program: C:\Code\vbTest.exe
Damage: before normal block (#xxxx) at 0xYYYYYYYY
(Press Retry to debug the application)Strangely enough, I was able to track the error down to occuring when I called the delete array[i]; line (and only on some, seemingly random, values of i)
What is strange is how I fixed it. I found two seperate options that seemed to work. The first was simply changing the compiler configuration from debug to release version, and it got rid of the error.
The second fix, and even stranger, involves only the code that manipulated the array. To quickly cap what I'm doing, I'm taking an image array (grayscale, in bytes) that has already been applied a smoothen and edge-detection (thresholded to is/isNot edge) routines, and this one "marks" the possible locations of a center pixel for each edge pixel given.
The "marking" is simply taking a possible center coordinate, say (x,y), and incrementing that value of the array (ie: array[x][y]++) I found that if I keep the number of ++ operations done to the pixels to a minimum, this also got rid of the error. What I removed was two more lines of code that did:
array[x][y-1]++;
array[x][y+1]++;
Has anyone ever experience this before, or know what may be wrong with my code?
Thanx in advance, as always.
Destined
I've been having a little trouble with a dll, written in C++, interfacing with VB. Well, it's not the interfacing with VB that's the problem, but rather some strange memory errors occuring.
Oh, for the record, I'm using Visual Studio 6, SP5 on Win2000 Pro.
If any of you folks are familiar with the Hough transform, or variants of it, this might make more sense, but the idea should be seen from anyone. In this dll function, I am passed an array, and create my own 2d "matrix" to copy/edit/paste the data that was sent. What I'm wondering is if the following syntax is correct:
myFunc(byte* data, short width, short height)
{
int** array;
int i, j;
array = new int* [width];
for (i = 0; i < width; i++)
array[i] = new int [height];
...
for (i = 0; i < width; i++)
delete array[i];
delete array;
}I'm wondering if there's anything wrong with this syntax, other than checking to see if any of the values are NULL.
I'm asking this mainly because I was getting the weird errorDebug Error!
Program: C:\Code\vbTest.exe
Damage: before normal block (#xxxx) at 0xYYYYYYYY
(Press Retry to debug the application)Strangely enough, I was able to track the error down to occuring when I called the delete array[i]; line (and only on some, seemingly random, values of i)
What is strange is how I fixed it. I found two seperate options that seemed to work. The first was simply changing the compiler configuration from debug to release version, and it got rid of the error.
The second fix, and even stranger, involves only the code that manipulated the array. To quickly cap what I'm doing, I'm taking an image array (grayscale, in bytes) that has already been applied a smoothen and edge-detection (thresholded to is/isNot edge) routines, and this one "marks" the possible locations of a center pixel for each edge pixel given.
The "marking" is simply taking a possible center coordinate, say (x,y), and incrementing that value of the array (ie: array[x][y]++) I found that if I keep the number of ++ operations done to the pixels to a minimum, this also got rid of the error. What I removed was two more lines of code that did:
array[x][y-1]++;
array[x][y+1]++;
Has anyone ever experience this before, or know what may be wrong with my code?
Thanx in advance, as always.
Destined