be safer w/ malloc, and convert to uint32_t
enable switch creation index size to be specified