diff options
| author | Paul Eggert | 2015-11-07 23:52:17 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-11-07 23:52:57 -0800 |
| commit | 8a8613bcf4227dfe46a694b761e9575bdf6ca2ce (patch) | |
| tree | 01d9d994b9caacc831342ef1b32e033844fc06a6 /src/xrdb.c | |
| parent | 6ea4ff5a362a150fb9e22eff1d8f2b87d017b7a4 (diff) | |
| download | emacs-8a8613bcf4227dfe46a694b761e9575bdf6ca2ce.tar.gz emacs-8a8613bcf4227dfe46a694b761e9575bdf6ca2ce.zip | |
Prefer xpalloc to doubling buffers by hand
* src/lread.c (grow_read_buffer): New function, which uses xpalloc.
(read1): Use it for simplicity.
* src/macros.c (store_kbd_macro_char):
* src/minibuf.c (read_minibuf_noninteractive):
* src/term.c (encode_terminal_code):
* src/xrdb.c (magic_db):
Prefer xpalloc to growing buffers by hand.
This doesn’t fix any bugs, but simplifies the code a bit.
Diffstat (limited to 'src/xrdb.c')
| -rw-r--r-- | src/xrdb.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/xrdb.c b/src/xrdb.c index ce6e7d21edb..10bc76986e6 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -177,12 +177,8 @@ magic_db (const char *string, ptrdiff_t string_len, const char *class, | |||
| 177 | 177 | ||
| 178 | /* Do we have room for this component followed by a '\0'? */ | 178 | /* Do we have room for this component followed by a '\0'? */ |
| 179 | if (path_size - path_len <= next_len) | 179 | if (path_size - path_len <= next_len) |
| 180 | { | 180 | path = xpalloc (path, &path_size, path_len - path_size + next_len + 1, |
| 181 | if (min (PTRDIFF_MAX, SIZE_MAX) / 2 - 1 - path_len < next_len) | 181 | -1, sizeof *path); |
| 182 | memory_full (SIZE_MAX); | ||
| 183 | path_size = (path_len + next_len + 1) * 2; | ||
| 184 | path = xrealloc (path, path_size); | ||
| 185 | } | ||
| 186 | 182 | ||
| 187 | memcpy (path + path_len, next, next_len); | 183 | memcpy (path + path_len, next, next_len); |
| 188 | path_len += next_len; | 184 | path_len += next_len; |