First, I insert key=str1,value=header_buff
Second, I use str2 to lookup the pointer
Third, I free the pointer which I malloc'd, but failed. Why?
#include <stdio.h>
#include <glib.h>
int main()
{
  GHashTable *hash; ///define my hashtable
  char str1[20] = "key";
  char str2[20] = "key";
  char *header_buff = (char*) malloc(sizeof(char) * 1024 * 1024);
  memcpy(header_buff, "value", 5);
  printf("%p\n", header_buff);
  hash = g_hash_table_new(g_str_hash, g_direct_hash); ///here I use (g_str_hash, g_direct_hash)
  g_hash_table_insert(hash, str1, header_buff); /// insert the str1 as key
  char * c = (char*) g_hash_table_lookup(hash, str2); ///use str2 to find the value
  if (c)
  {
    printf("%s\n", c);   ///can print the string "value"
    printf("%p\n", c);
    free(c); ///the same address? but I can't free the mem!
    c = NULL;
  }
  return 0;
}
 
     
     
    