Thursday, October 17, 2019

multidimensional arrays in C on heap

For future reference I have 3D arrays below as sample snippet


//want to work on a 3D array on the heap
//first lest get a single then a 2D array working correctly on the heap

#define IMAGE_WIDTH 4
#define IMAGE_HEIGHT 3
#define CHANNELS 2

void experiment6()
{
int* array1D = NULL;
int* array2D = NULL;
int* array3D = NULL;

array1D = (int*)malloc(IMAGE_WIDTH * sizeof(int));
for (int i = 0; i < IMAGE_WIDTH; i++)
{
array1D[i] = i;
}
for (int i = 0; i < IMAGE_WIDTH; i++)
{
printf("[%d]=%d ",i, array1D[i]);
}

printf("\n");

array2D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH;j++)
{
array2D[i * IMAGE_WIDTH + j ] = i * IMAGE_WIDTH + j;
}
}
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
printf("[%d]=%d ", i * IMAGE_WIDTH + j, array2D[i * IMAGE_WIDTH + j]);
}
printf("\n");
}

array3D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * CHANNELS * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
for (int k = 0; k < CHANNELS; k++)
{
array3D[(i* IMAGE_WIDTH * CHANNELS) + (CHANNELS*j) + k] = (i * IMAGE_WIDTH  * CHANNELS) + (CHANNELS * j) + k;
//printf("%d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k);

}
}
}

for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
for (int k = 0; k < CHANNELS; k++)
{
// array2D[(i * IMAGE_WIDTH  CHANNELS) + (CHANNELS * j) + k] = (i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k;
printf("[%d] = %d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k, array3D[(i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k]);
}
}
printf("\n");
}


if (array1D != NULL) 
{
free(array1D);
}
if (array2D != NULL)
{
free(array2D);
}
if (array3D != NULL)
{
free(array3D);
}


}

Monday, October 14, 2019

git (gitlab) windows password reset not propagated correctly

After you change your password, this doesn't propagate to the windows credential manager passwords. I went and manually modified each one and that seems to work.


Even easier for me:
Had a bunch of tokens, removed them all related to git repos in windows credential manager. Exit and restarted sourcetree. Forces a request for a new token.


Monday, October 07, 2019

debugging with symbols (VTune)

good article here:
https://docs.microsoft.com/en-us/windows/win32/dxtecharts/debugging-with-symbols

I used this syntax:
srv*c:\temp\msft\symbols*https://msdl.microsoft.com/download/symbols

looks like it worked.

This article makes you think you can get nvidia symbols, but you can't if you read it carefully. They are just using that server to allow retroactive driver binaries to be pulled.
https://developer.nvidia.com/nvidia-driver-symbol-server