How to properly malloc item in struct array hashmap in C
问题 In the following code, I'm using malloc for adding a new item to a hashmap. I thought I've checked all the boxes for properly using malloc, but valgrind says I've got a memory leak on them. Can someone point me to where I've gone wrong? #include <stdlib.h> #include <string.h> typedef struct node { char content[46]; struct node* next; } node; typedef node* hashmap_t; int main (int argc, char *argv[]) { hashmap_t hashtable[1000]; node *n = malloc(sizeof(node)); if(n == NULL) return 0; hashmap_t