Beispiel #1
0
heap* heap_new() {
  heap* h = (heap *) SAFEMALLOC(sizeof(heap_type));
  h->allocated = HEAP_BASE_SIZE;
  h->count = 0;
  h->data = (heap_type *) SAFEMALLOC(HEAP_BASE_SIZE * sizeof(heap_type));
  return h;
}
Beispiel #2
0
// TC14: recursion 
int * make(int n) {
	int *y = SAFEMALLOC(10);
	if (n > 0) {
		free(y);
		return make(n - 1);
	} else {
		free(y);
		return SAFEMALLOC(10);
	}
}
Beispiel #3
0
int main(){

	int *a,*b,*c;
	if(a)
		a = SAFEMALLOC(1);
	else
		a = SAFEMALLOC(1);
	b = a;
	foo(b);

}
Beispiel #4
0
int* foo(){
	int** x = SAFEMALLOC(10);
	int** y = SAFEMALLOC(10);
	bar1(x);
	free(*x);
	free(x);

	bar1(y);
	free(y);

	printf("%d",x,y);
}
Beispiel #5
0
int func(){

	int* p = SAFEMALLOC(1);

	free(p);

	int *q = SAFEMALLOC(1);

	if(q==0)
		return -1;

	free(q);

}
Beispiel #6
0
int func(){
	static int* q;
	int *p = SAFEMALLOC(10);
	q = p;
	printf("%d%d",p,q);
	//free(p);
}
Beispiel #7
0
int main(int arg1)
{
    S *p;
    char str1[10] = "STRING 1";
    char str2[10] = "STRING 2";

    p = (S*)SAFEMALLOC(sizeof(S));
    if( p == NULL)
        return -1;

    p->p1 = (char *)PLKLEAKFP(sizeof(char)*10);
    if( p->p1 == NULL) {
        free(p);
        return -1;
    }
    /*
    p->p2 = (char *)malloc(sizeof(char)*10);
    if( p->p2 == NULL){
    		if( p->p1 != NULL)
    				free(p->p1);
    				free(p);
    				return -1;
    }
    */
    strcpy(p->p1, str1);
    strcpy(p->p2, str2);

    free(p->p1);
    free(p->p2);
    free(p);
    return arg1;
}
Beispiel #8
0
int main(){
	int *k;	
	int *a = SAFEMALLOC(sizeof(int));
	foo(a);
	*a = 100;
	k = a;
	printf("%d,%d,%d,%d,",*k,*a,a,k);
}
Beispiel #9
0
int main(){

	//int* a[100];
	int i;
	a[i] = SAFEMALLOC(10);
	printf("%d",a[i]);

}
Beispiel #10
0
// from spec2000 
void *my_malloc (int size) {

	 void *ret;

	  if ((ret = SAFEMALLOC (size)) ==0 ) {
		      printf("Error:  Unable to malloc memory.  Aborting.\n");
			      exit (1);
				   }
	   return (ret);
}
Beispiel #11
0
Datei: sp6.c Projekt: dtzWill/SVF
list make_list(int n) {
	  int i;
	  list hd = (list)SAFEMALLOC(sizeof(List));
	  list p = hd; 
	  /*
		    for (i=0; i<n; i++) {
				    p->next = (list)malloc(sizeof(List)); 
				    p = p->next;
	   	  }
			  p->next = 0;
			  */
			    return hd;
}
Beispiel #12
0
Datei: sp2.c Projekt: dtzWill/SVF
int main(int arg1)
{
		char *p1;
		char *p2;
		int y = 10;
		p1 = (char *)SAFEMALLOC(sizeof(char)*10);
				
		if( p1 == 0) 
			  return 1;
							
		p2 = (char *)SAFEMALLOC(sizeof(char)*10);
		if( p2 == 0)	{
			  if(p1 != 0){
				    free(p1);
			  }
			  return 2;
		}
		free(p1);
				p1 = p2;
		free(p1);
		return 0;
}
Beispiel #13
0
int func(){

	int* p = PLKMALLOC(1);

	if(!p)
		return -1;
	
	int *q = SAFEMALLOC(1);

	if(!q)
		return -1;

	free(p);

	free(q);

}
Beispiel #14
0
void readmin(FOO* net1){
	net1->f1 = (int*)SAFEMALLOC(sizeof(int));
	net1->f2 = (int*)SAFEMALLOC(2);
	net1->f3 = (int*)SAFEMALLOC(3);
}
Beispiel #15
0
int *aliasing(int **p) {
	*p = SAFEMALLOC(10);
	return *p;
}