title: Accessing NULL pointers
body: <p>This is part of my code... and i have several major problems that im stuck on...
  ok most of the problem that i can see so far has been fixed... but im still lost on where to free the memory.
  this is the error message when i end the program :S</p>
  
  <pre><code> HEAP SUMMARY:
  ==15468==     in use at exit: 20 bytes in 1 blocks
  ==15468==   total heap usage: 1 allocs, 0 frees, 20 bytes allocated
  ==15468== 
  ==15468== 20 bytes in 1 blocks are definitely lost in loss record 1 of 1
  ==15468==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
  ==15468==    by 0x8048601: newnode (myassignment.c:27)
  ==15468==    by 0x804885E: insertavl (myassignment.c:88)
  ==15468==    by 0x8048B33: main (myassignment.c:156)
  ==15468== 
  ==15468== LEAK SUMMARY:
  ==15468==    definitely lost: 20 bytes in 1 blocks
  ==15468==    indirectly lost: 0 bytes in 0 blocks
  ==15468==      possibly lost: 0 bytes in 0 blocks
  ==15468==    still reachable: 0 bytes in 0 blocks
  ==15468==         suppressed: 0 bytes in 0 blocks
  ==15468== 
  ==15468== For counts of detected and suppressed errors, rerun with: -v
  ==15468== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 13 from 8)
  typedef struct node *tree;
  
  struct node {
     int data;
     char name;
     int height;
     struct node *left;
     struct node *right;
  };
  
  
  
  
  static tree newnode(int d,char n){    
     tree t = malloc(sizeof(struct node));
     t-&gt;data = d;
     t-&gt;name=n;
     t-&gt;left = NULL;
     t-&gt;right = NULL;
     memoize(t);
     return t;
  }
  
  static tree modnode(int d, char n,tree t){
     if (d &gt; t-&gt;data){
         t-&gt;data=d;
         t-&gt;name=n;
         t-&gt;right = t-&gt;right;}
     else{
         t-&gt;data=t-&gt;data;
         t-&gt;name=t-&gt;name;
         t-&gt;right = t-&gt;right;}
    return t;
  }
  
  
  
  tree insertavl(tree t, int d,const char *n){                 
     if (t == NULL) return newnode(d,*n);
     else if (t-&gt;name==*n) return modnode(d,*n,t-&gt;right);// &lt;=========(1)
     else {                                                
        printf("went right");
        setright(t, insertavl(t-&gt;right, d,n));
     }
     return t;
  }
  
  
  int main(void) {
    int i = 0;
    char foo[11];
    int c;
    tree t= NULL;
    for(c=0;c&lt;=1000;c++) {
      i = readstring(foo,10);
      if(i == 0) break;
      if (strcmp("score",foo)==0){
     int a=0;
     int point;
     char n[21];
     printf ("Enter name \n");
     a=readstring (n,20);
     printf ("Enter score \n");
     scanf("%d", &amp;point);
     t=insertavl(t,point,n);}
     if (strcmp("highscore",foo)==0){
         printf ("%d \n", highsc(t));}
  
     if (t==NULL){
        printf ("false");}
      }
     return 0;
   }
  </code></pre>
  
  <p>i know my program is not efficient but i wan to fix the error first.,,any help is appreciated! </p>