38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
void AddOneToNeighbors(int * ptr_mat, int * ptr_loc, unsigned int row_size, unsigned int col_size)
|
|
{
|
|
int * ptr_last = ptr_mat + (row_size * col_size);
|
|
int * ptr_temp = ptr_loc - col_size - ONE;
|
|
for (unsigned short count = ZERO; count < THREE; count++)
|
|
{
|
|
if (ptr_temp >= ptr_mat &&
|
|
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size) - ONE))
|
|
{
|
|
(*(ptr_temp))++;
|
|
}
|
|
ptr_temp++;
|
|
}
|
|
|
|
ptr_temp = ptr_loc - ONE;
|
|
for (unsigned short count = ZERO; count < TWO; count++)
|
|
{
|
|
if (ptr_temp >= ptr_mat &&
|
|
ptr_temp < ptr_last &&
|
|
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size)))
|
|
{
|
|
(*(ptr_temp))++;
|
|
}
|
|
ptr_temp += TWO;
|
|
}
|
|
|
|
ptr_temp = ptr_loc + col_size - ONE;
|
|
for (unsigned short count = ZERO; count < THREE; count++)
|
|
{
|
|
if (ptr_temp < ptr_last &&
|
|
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size) + ONE))
|
|
{
|
|
(*(ptr_temp))++;
|
|
}
|
|
ptr_temp++;
|
|
}
|
|
}
|