* Changes today consist just of some code hardening.
authorFrank Ch. Eigler <fche@redhat.com>
Wed, 18 Mar 1998 19:33:33 +0000 (19:33 +0000)
committerFrank Ch. Eigler <fche@redhat.com>
Wed, 18 Mar 1998 19:33:33 +0000 (19:33 +0000)
sim/mips/sky-pke.c

index b35ef1267f6bbb75a18db4788af1c6f79e28e3b6..1689fc1513dad065bdc1b4b39e62f3cafb7fe111 100644 (file)
@@ -701,12 +701,16 @@ pke_fifo_fit(struct pke_fifo* fifo)
       new_qw = zalloc(new_length * sizeof(struct fifo_quadword*));
       ASSERT(new_qw != NULL);
 
-      /* copy over old pointers to beginning of new block */
-      memcpy(new_qw, fifo->quadwords,
-            fifo->length * sizeof(struct fifo_quadword*));
-
-      /* free old block */
-      zfree(fifo->quadwords);
+      /* copy over old contents, if any */
+      if(fifo->quadwords != NULL)
+       {
+         /* copy over old pointers to beginning of new block */
+         memcpy(new_qw, fifo->quadwords,
+                fifo->length * sizeof(struct fifo_quadword*));
+         
+         /* free old block */
+         zfree(fifo->quadwords);
+       }
 
       /* replace pointers & counts */
       fifo->quadwords = new_qw;
@@ -1699,7 +1703,7 @@ pke_code_direct(struct pke_device* me, unsigned_4 pkecode)
          
          /* collect word into quadword */
          *A4_16(&fifo_data, 3 - (i % 4)) = *operand;
-         
+
          /* write to GPUIF FIFO only with full quadword */
          if(i % 4 == 3)
            {
@@ -1708,7 +1712,6 @@ pke_code_direct(struct pke_device* me, unsigned_4 pkecode)
                            & fifo_data,
                            16);
            } /* write collected quadword */
-         
        } /* GPUIF xfer loop */
       
       /* done */