[comp.bugs.4bsd] Berkeley curses. newwin memory allocation

pbm@cybvax0.uucp (Paul B. McBride) (01/30/91)

In looking at the sources to Berkeley curses on uunet, it looks to me
as though newwin.c is allocating 4 times the amount of memory required
to store each window (on a VAX).

The following line in "newwin.c" allocates a buffer for each line of characters
on the screen. 

	if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) {

where "_y" is defined as:

	char		**_y;

Depending on the difference between the pointer size and the character
size of the machine this results in 2 to 4 times the number of bytes
required.  On a VAX "sizeof win->_y[0]" is 4. What should be used
is "sizeof win->_y[0][0]" which is 1. As follows:

	if ((win->_y[i] = malloc(nc * sizeof win->_y[0][0])) == NULL) {

This particular problem is quite distressing to me since the reason I
was looking at the sources was to see how the STANDOUT flag was
stored as the eight bit of each character thus preventing 8 bit characters
from being processed properly. So here we have 24 wasted bits at
each screen location and the STANDOUT bit stingily stored in the
eight bit of each character.

What is the solution to handling full 8 bit character sets within curses?
Does System V character attributes do the trick or not?

Please mail responses to uunet!cybvax0!pbm. Thank you.
-- 
					Paul B. McBride (cybvax0!pbm)
					Cybermation, Inc. (617) 396-6500
					200 Boston Ave., Medford MA 02155