Skip to content
Permalink
Browse files

Stop using 'short' for line and allocation sizes

Yes, yes, it probably made sense 30 years ago as a way to save a tiny
amount of memory, but especially when interspersed in structures that
have pointers (aligned to 64 bits these days), it's not even saving
memory today.  And it makes us fail in nasty ways when looking at files
with long lines.

So just make them 'int'.  And if you have a line that is longer than
2GB, you only have yourself to blame.  I no longer care.

In case anybody care, the "test-case" for this was a lovely UDDF file
with a binary divecomputer dump encoded as an XML element.  Resulting in
a lovely 41kB single line.  Not what poor micro-emacs was designed for,
I'm afraid.

I really should just learn another editor, rather than continue to
polish this turd.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information...
torvalds committed Feb 22, 2013
1 parent 25f0141 commit fa00fe882f719351fdf7a4c4100baf4f3eab4d61
Showing with 8 additions and 8 deletions.
  1. +6 −6 estruct.h
  2. +2 −2 line.h
@@ -412,9 +412,9 @@ struct window {
struct buffer *w_bufp; /* Buffer displayed in window */
struct line *w_linep; /* Top line in the window */
struct line *w_dotp; /* Line containing "." */
short w_doto; /* Byte offset for "." */
struct line *w_markp; /* Line containing "mark" */
short w_marko; /* Byte offset for "mark" */
int w_doto; /* Byte offset for "." */
int w_marko; /* Byte offset for "mark" */
char w_toprow; /* Origin 0 top row of window */
char w_ntrows; /* # of rows of text in window */
char w_force; /* If NZ, forcing row. */
@@ -452,14 +452,14 @@ struct window {
struct buffer {
struct buffer *b_bufp; /* Link to next struct buffer */
struct line *b_dotp; /* Link to "." struct line structure */
short b_doto; /* Offset of "." in above struct line */
struct line *b_markp; /* The same as the above two, */
short b_marko; /* but for the "mark" */
struct line *b_linep; /* Link to the header struct line */
int b_doto; /* Offset of "." in above struct line */
int b_marko; /* but for the "mark" */
int b_mode; /* editor mode of this buffer */
char b_active; /* window activated flag */
char b_nwnd; /* Count of windows on buffer */
char b_flag; /* Flags */
int b_mode; /* editor mode of this buffer */
char b_fname[NFILEN]; /* File name */
char b_bname[NBUFN]; /* Buffer name */
#if CRYPT
@@ -490,7 +490,7 @@ struct buffer {
*/
struct region {
struct line *r_linep; /* Origin struct line address. */
short r_offset; /* Origin struct line offset. */
int r_offset; /* Origin struct line offset. */
long r_size; /* Length in characters. */
};

4 line.h
@@ -14,8 +14,8 @@
struct line {
struct line *l_fp; /* Link to the next line */
struct line *l_bp; /* Link to the previous line */
short l_size; /* Allocated size */
short l_used; /* Used size */
int l_size; /* Allocated size */
int l_used; /* Used size */
char l_text[1]; /* A bunch of characters. */
};

0 comments on commit fa00fe8

Please sign in to comment.
You can’t perform that action at this time.