Hello,

in mrxvt, there are several buffers. One of them is v_buffer which is 
the buffer of what is written to the child program (most often bash) as 
input. This one is dynamic (its size increases depending on the needs 
and space is freed when only a very small part of it is used).

We have other another buffer which is -- at the opposite -- the output 
from the child program: cmdbuf_base. This one is of fixed size, 
allocated from the beginning: BUFSIZ (defined as 4096 bytes in rxvt.h).

Why not make it dynamic as well? The advantages are:
- we don't have constantly 4096 bytes for each tab, whether this is 
really necessary or not. But is it such an issue 4096 bytes on current 
machines with so much memory? Probably is it if we want mrxvt to work as 
well on old machines?
- could there really be cases where there is so much output at once that 
this implies a loss of data? I am not sure of this because in some 
places there are some kind of watchdog. But at the opposite, this case 
has been taken into account in at least one function: rxvt_cmd_write in 
command.c.
- probably better code to be dynamic as a general matter of fact, isn't it?

The best advantages of a static array instead of a dynamic pointer is 
not having to reallocate and check size all the time, I guess. But I am 
not expert enough in C so that I could say if it is really worth it (is 
reallocation really time consuming and to be avoided as much as possible 
maybe?).
Of course there shall be some minimum buffer size (considering in any 
terminal, we will see some output) and we could decide to free only when 
there is something like 80% of the space which is wasted. This way we 
won't reallocate too much, but still be dynamic in the use...

Anyway I had a look and even made some beginning of changes on my local 
copy. I think such change won't be too hard to make. I probably can make 
it for tomorrow night if I don't fall asleep directly when coming from 
work :p. What do you think?

Jehan

P.S.: I saw a similar comment by Gautam about the tabs in rxvlib.h:

     /*
      * term_t structures and pointers.
      *
      * 2006-08-18 gi1242 TODO: This should be an array that grows 
dynamically in
      * size. Plus we should only reserve enough memory for a our currently
      * displayed term structures.
      */

They are indeed initialized the same way as the buffer, by a fixed 
length array of size MAX_PAGES. Probably can this be changed as well 
later on.
So instead of loading from the start MAX_PAGES with each one a buffer of 
BUFSIZ, the next version of mrxvt may be able to use only the necessary 
memory at all time...

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Materm-devel mailing list
Materm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/materm-devel
mrxvt home page: http://materm.sourceforge.net

Reply via email to