I am trying to make an ssd1306 library for learning stm32, for which I've made an `*init[]` array. All of the defines and macros return `uint8_t`. The idea behind this was that I'll detect where NULL is in the memory and stop incrementing (the logical bug would be that this would fail if there were exactly 4,8,12,16... array elements in the rows, which is never the case). In this, I assumed that all the memory addresses allocated to the array would be initialized to 0x00 (obviously not), and I ran into a problem where a single random byte would corrupt everything. So, I was looking for a way to make all the memory locations 0x00. Feel free to suggest any new ways I could do the same thing.

I could declare `*init[]`, do `calloc`, and then initialize every sub-array individually, but that would make adding new init parameters that much more cumbersome. If all else fails, ill use it.

[![Array memory locations](https://i.stack.imgur.com/ZerfR.png)](https://i.stack.imgur.com/ZerfR.png)

[![Memory view showing random bytes messing with it](https://i.stack.imgur.com/lYa7o.png)](https://i.stack.imgur.com/lYa7o.png)

```
uint8_t *init[]= {
              (uint8_t[]){MUX_RATIO_ADDR, SET_MUX_RATIO(0X1F)},
              (uint8_t[]){DISPLAY_OFFSET_ADDR, SET_DISPLAY_OFFSET(0X00)},
              (uint8_t[]){DISPLAY_START_LINE(0)},
              (uint8_t[]){SEG_REMAP(0x00)},
              (uint8_t[]){SCAN_DIRECTION(0X00)},
              (uint8_t[]){COM_CONFIG_ADDR, COM_CONFIG(0X01)},
              (uint8_t[]){CONTRAST_CONTROL_ADDR, SET_CONTRAST(0X7F)},
              (uint8_t[]){VER_ADDR_MODE},
              (uint8_t[]){0X21, 0X3F, 0X7F},
              (uint8_t[]){0X22, 0X4, 0X7},
              (uint8_t[]){DISPLAY_ON(0)},
              (uint8_t[]){INVERSE_MODE(0)},
              (uint8_t[]){DISPLAY_CLK_DIVIDE_ADDR, DISPLAY_CLK_DIVIDE(1,8)},
              (uint8_t[]){0xdb, 0x40},
              (uint8_t[]){CHARGE_PUMP_ADDR, CHARG_PUMP_ON},
              (uint8_t[]){NORMAL_MODE(1)}
      };
      for (int i=0; i<sizeof(init)/sizeof(init[0]); i++) {
          for(int j=0; init[i][j] != '\0'; j++) {
              HAL_I2C_Mem_Write(&hi2c1, DEV_ADDR, COMMAND_MODE, 1, &init[i][j], 1, 50);
          }
      }

```

HAL function declaration for referance:

`HAL_StatusTypeDef HAL_I2C_Mem_Write (I2C_HandleTypeDef*, uint16_t , uint16_t , uint16_t, uint8_t*, uint16_t , uint32_t );`