title: Pointer not being set to NULL (C)
body: <p>I'm trying to figure out how to set a struct pointer to NULL within a function.  Here is my code.  </p>
  
  <pre><code>struct object
  {
      char* name;
      int type;
  };
  
  struct object* createObject(char* new_name, int new_type)
  {
      struct object* new_object = (struct object*) malloc(sizeof(struct object));
  
      new_object-&gt;name = (char*) malloc(sizeof(char) * (strlen(new_name) + 1));
  
      strcpy(new_object-&gt;name, new_name);
      new_object-&gt;type = new_type;
  
      return new_object;
  }
  
  void freeData(struct object* clearedObject)
  {
      free(clearedObject-&gt;name);
      clearedObject-&gt;name = NULL;
      clearedObject-&gt;type = 0;
  }
  
  void freeObject(struct object* deadObject)
  {
      free(deadObject);
      deadObject = NULL;
  }
  
  int main(void)
  {
      struct object* my_object = createObject("Test", 1234);
  
      printf("Pointer to Object: %p\n", my_object);
      printf("Pointer to Name  : %p\n", my_object-&gt;name);
      printf("Name: %s\n", my_object-&gt;name);
      printf("Type: %d\n", my_object-&gt;type);
      printf("\n");
  
      freeData(my_object);
  
      printf("Pointer to Object: %p\n", my_object);
      printf("Pointer to Name  : %p\n", my_object-&gt;name);
      printf("Name: %s\n", my_object-&gt;name);
      printf("Type: %d\n", my_object-&gt;type);
      printf("\n");
  
      freeObject(my_object);
  
      printf("Pointer to Object: %p\n", my_object);
  }
  </code></pre>
  
  <p>This is what the code outputs:</p>
  
  <pre><code>Pointer to Object:  005E17B8
  Pointer to Name  :  005E17D8
  Name:  Test
  Type:  1234
  
  Pointer to Object:  005E17B8
  Pointer to Name  :  00000000
  Name:  (null)
  Type:  0
  
  Pointer to Object:  005E17B8
  </code></pre>
  
  <p>Why can I set the pointer to the struct's name to NULL within a function, but not the actual struct pointer itself?  How can this be done?<br>
  I need to set my_object to NULL from within the function, how would this be possible?
  Thanks.</p>