For safety, use calloc() instead of just malloc()
Use calloc() to replace malloc() + memset()