freeing dynamic memory in the r.le programs

Sun Jul 18 17:31:38 EDT 1993

I have used the following code to allocate and free memory in one of the
r.le programs:

	pt = (int *)G_calloc(100, sizeof(int));


	for (i=0; i<100; i++)

This works fine on Sun systems with a version of Unix System V, but
failsproduces the compiler message "incompatible integer/pointer combination"
on Apollo machines with bsd4.3.  I forgot to mention that the declaration
is "int   *pt;" before the above code.  This problem was found by Lars

Lars was able to fix the problem on the Apollo by replacing free(pt[i])
with free(&pt[i]).  However, when I do this on my Sun I quickly run out
of memory, indicating that the memory is not being freed correctly.

I am simply a beginning programmer and can't find anything in the usual
C books about this.  Anyone know a universal method for freeing memory
that will work with System V and bsd?

	Bill Baker
	bakerwl at
	Univ. of Wyoming, Laramie

More information about the grass-dev mailing list