[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Sunview from KCL.

> It all seemed OK until I tried to run it. In the C code, I get a "FREE(3)
> error". This occurs within Suntool's window_create function. My guess is that
> the memory allocator used inside the Suntool libaries is conflicting with the
> memory manager of KCL. Anyone had any luck with this kind of situation?

The problem used to (and may still) be that KCL defines its own
malloc but does not define its own valloc or memalign.  I used
to fix it by defining them as follows:

extern object malloc_list;

char *
memalign(alig, size)
int alig, size;
	object x;
	char *bigblock, *actual;

	bigblock = alloc_contblock(size+alig);
	actual = (char *)((int)(bigblock+alig-1) & ~alig);
	insert_contblock(bigblock, actual-bigblock);
	insert_contblock(actual+size, alig-(actual-bigblock));
	x = alloc_simple_string(size);
	x->st.st_self = actual;
	malloc_list = make_cons(x, malloc_list);

char *valloc(size)
int size;
    return memalign(getpagesize(), size);

-- Jeff