changeset 3:500d0e2fabfb

made pure C and added .brch__defaul and eol handling
author Me@portablequad
date Sat, 11 Feb 2012 20:27:13 -0800
parents 4d8a1e0f4336
children 9911e62c4fee d3ca41a44a21
files .brch__default .hgeol PriorityQueue.c PriorityQueue.h TestPriorityQueue.c
diffstat 5 files changed, 28 insertions(+), 22 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.brch__default	Sat Feb 11 20:27:13 2012 -0800
     1.3 @@ -0,0 +1,1 @@
     1.4 +The default branch is for use with normal C code.  Other branches specialize the library for use with VMS..  they may need VMS header files, and the working directory may be located at various different positions relative to the VMS implementation.
     1.5 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgeol	Sat Feb 11 20:27:13 2012 -0800
     2.3 @@ -0,0 +1,14 @@
     2.4 +
     2.5 +[patterns]
     2.6 +**.py = native
     2.7 +**.txt = native
     2.8 +**.c = native
     2.9 +**.h = native
    2.10 +**.cpp = native
    2.11 +**.java = native
    2.12 +**.class = bin
    2.13 +**.jar = bin
    2.14 +**.sh = native
    2.15 +**.pl = native
    2.16 +**.jpg = bin
    2.17 +**.gif = bin
     3.1 --- a/PriorityQueue.c	Thu Feb 09 15:55:54 2012 +0100
     3.2 +++ b/PriorityQueue.c	Sat Feb 11 20:27:13 2012 -0800
     3.3 @@ -5,25 +5,12 @@
     3.4   * Author: hausers@cs.tu-berlin.de
     3.5   */
     3.6  
     3.7 -#include <limits.h>
     3.8 -#include <stdio.h>
     3.9 -#include <string.h>
    3.10 -
    3.11  #include "PriorityQueue.h"
    3.12 -#ifndef DEBUG
    3.13 -#include "../../VMS_Implementations/VMS_impl/vmalloc.h"
    3.14 -#endif
    3.15  
    3.16  #define left(i) 2*i
    3.17  #define right(i) 2*i+1
    3.18  #define parent(i) i/2
    3.19  
    3.20 -#ifdef DEBUG
    3.21 -#include <stdlib.h>
    3.22 -#define VMS__malloc malloc
    3.23 -#define VMS__free free
    3.24 -#endif 
    3.25 -
    3.26  void swap (PrioQueueStruc *Q, int a, int b) {
    3.27  	void *valTmp;
    3.28  	int keyTmp;
    3.29 @@ -69,21 +56,21 @@
    3.30  	newSize= 2*oldSize;
    3.31  
    3.32  	Q->maxSize= newSize;
    3.33 -	newData= VMS__malloc(Q->maxSize*sizeof(heapNode));
    3.34 +	newData= malloc(Q->maxSize*sizeof(heapNode));
    3.35  	oldData= Q->data;
    3.36  
    3.37  	memcpy(newData,oldData,Q->maxSize*sizeof(heapNode));
    3.38  	Q->data= newData;
    3.39  
    3.40 -	VMS__free(oldData);
    3.41 +	free(oldData);
    3.42  }
    3.43  
    3.44  
    3.45 -PrioQueueStruc* makeVMSPrioQ () {
    3.46 +PrioQueueStruc* makePrioQ () {
    3.47  	PrioQueueStruc *retQ;
    3.48 -	retQ= VMS__malloc(sizeof(PrioQueueStruc));
    3.49 +	retQ= malloc(sizeof(PrioQueueStruc));
    3.50  	retQ->maxSize= 1024;
    3.51 -	retQ->data= VMS__malloc(retQ->maxSize*sizeof(heapNode));
    3.52 +	retQ->data= malloc(retQ->maxSize*sizeof(heapNode));
    3.53  	retQ->size= 0;
    3.54  	return retQ;
    3.55  }
    3.56 @@ -124,6 +111,6 @@
    3.57  }
    3.58  
    3.59  void freePrioQ (PrioQueueStruc *Q) {
    3.60 -	VMS__free(Q->data);
    3.61 -	VMS__free(Q);
    3.62 +	free(Q->data);
    3.63 +	free(Q);
    3.64  }
     4.1 --- a/PriorityQueue.h	Thu Feb 09 15:55:54 2012 +0100
     4.2 +++ b/PriorityQueue.h	Sat Feb 11 20:27:13 2012 -0800
     4.3 @@ -10,6 +10,10 @@
     4.4  
     4.5  #include <stdbool.h>
     4.6  
     4.7 +#include <limits.h>
     4.8 +#include <stdio.h>
     4.9 +#include <string.h>
    4.10 +
    4.11  typedef struct _PrioQueueStruc PrioQueueStruc;
    4.12  typedef struct _heapNode heapNode;
    4.13  
    4.14 @@ -25,7 +29,7 @@
    4.15  	heapNode *data;
    4.16  };
    4.17  
    4.18 -PrioQueueStruc* makeVMSPrioQ();
    4.19 +PrioQueueStruc* makePrioQ();
    4.20  void* getFirstPrioQ (PrioQueueStruc *Q);
    4.21  void* popPrioQ (PrioQueueStruc *Q);
    4.22  bool insertPrioQ (void *val, int key, PrioQueueStruc *Q);
     5.1 --- a/TestPriorityQueue.c	Thu Feb 09 15:55:54 2012 +0100
     5.2 +++ b/TestPriorityQueue.c	Sat Feb 11 20:27:13 2012 -0800
     5.3 @@ -14,7 +14,7 @@
     5.4  static char *first,*second,*third;
     5.5  
     5.6  int init_suite (void) {
     5.7 -	if (NULL == (Q= makeVMSPrioQ())) return -1;
     5.8 +	if (NULL == (Q= makePrioQ())) return -1;
     5.9  	else return 0;
    5.10  }
    5.11