Mercurial > vim
comparison src/if_mzsch.c @ 20007:aadd1cae2ff5 v8.2.0559
patch 8.2.0559: clearing a struct is verbose
Commit: https://github.com/vim/vim/commit/a80faa8930ed5a554beeb2727762538873135e83
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 12 19:37:17 2020 +0200
patch 8.2.0559: clearing a struct is verbose
Problem: Clearing a struct is verbose.
Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Apr 2020 19:45:05 +0200 |
parents | d776967d0f0d |
children | d571231175b4 |
comparison
equal
deleted
inserted
replaced
20006:aee3c9266968 | 20007:aadd1cae2ff5 |
---|---|
1925 if (win->w_mzscheme_ref != NULL) | 1925 if (win->w_mzscheme_ref != NULL) |
1926 return (Scheme_Object *)WINDOW_REF(win); | 1926 return (Scheme_Object *)WINDOW_REF(win); |
1927 | 1927 |
1928 MZ_GC_REG(); | 1928 MZ_GC_REG(); |
1929 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window)); | 1929 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window)); |
1930 vim_memset(self, 0, sizeof(vim_mz_window)); | 1930 CLEAR_POINTER(self); |
1931 #ifndef MZ_PRECISE_GC | 1931 #ifndef MZ_PRECISE_GC |
1932 scheme_dont_gc_ptr(self); // because win isn't visible to GC | 1932 scheme_dont_gc_ptr(self); // because win isn't visible to GC |
1933 #else | 1933 #else |
1934 win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL); | 1934 win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL); |
1935 #endif | 1935 #endif |
2309 if (buf->b_mzscheme_ref) | 2309 if (buf->b_mzscheme_ref) |
2310 return (Scheme_Object *)BUFFER_REF(buf); | 2310 return (Scheme_Object *)BUFFER_REF(buf); |
2311 | 2311 |
2312 MZ_GC_REG(); | 2312 MZ_GC_REG(); |
2313 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer)); | 2313 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer)); |
2314 vim_memset(self, 0, sizeof(vim_mz_buffer)); | 2314 CLEAR_POINTER(self); |
2315 #ifndef MZ_PRECISE_GC | 2315 #ifndef MZ_PRECISE_GC |
2316 scheme_dont_gc_ptr(self); // because buf isn't visible to GC | 2316 scheme_dont_gc_ptr(self); // because buf isn't visible to GC |
2317 #else | 2317 #else |
2318 buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL); | 2318 buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL); |
2319 #endif | 2319 #endif |
2632 MZ_GC_DECL_REG(2); | 2632 MZ_GC_DECL_REG(2); |
2633 MZ_GC_VAR_IN_REG(0, line); | 2633 MZ_GC_VAR_IN_REG(0, line); |
2634 MZ_GC_VAR_IN_REG(1, rest); | 2634 MZ_GC_VAR_IN_REG(1, rest); |
2635 MZ_GC_REG(); | 2635 MZ_GC_REG(); |
2636 | 2636 |
2637 array = ALLOC_MULT(char *, new_len + 1); | 2637 array = ALLOC_CLEAR_MULT(char *, new_len + 1); |
2638 vim_memset(array, 0, (new_len+1) * sizeof(char *)); | |
2639 | 2638 |
2640 rest = line_list; | 2639 rest = line_list; |
2641 for (i = 0; i < new_len; ++i) | 2640 for (i = 0; i < new_len; ++i) |
2642 { | 2641 { |
2643 line = SCHEME_CAR(rest); | 2642 line = SCHEME_CAR(rest); |
2816 MZ_GC_DECL_REG(2); | 2815 MZ_GC_DECL_REG(2); |
2817 MZ_GC_VAR_IN_REG(0, line); | 2816 MZ_GC_VAR_IN_REG(0, line); |
2818 MZ_GC_VAR_IN_REG(1, rest); | 2817 MZ_GC_VAR_IN_REG(1, rest); |
2819 MZ_GC_REG(); | 2818 MZ_GC_REG(); |
2820 | 2819 |
2821 array = ALLOC_MULT(char *, size + 1); | 2820 array = ALLOC_CLEAR_MULT(char *, size + 1); |
2822 vim_memset(array, 0, (size+1) * sizeof(char *)); | |
2823 | 2821 |
2824 rest = list; | 2822 rest = list; |
2825 for (i = 0; i < size; ++i) | 2823 for (i = 0; i < size; ++i) |
2826 { | 2824 { |
2827 line = SCHEME_CAR(rest); | 2825 line = SCHEME_CAR(rest); |