gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2578-gb7d8b6


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-2578-gb7d8b6e
Date: Wed, 21 Jun 2017 09:57:56 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  b7d8b6ebcd5dd714bc21acf7637d9a651e2f7ea7 (commit)
      from  4264c894681d11d4a5ce694aa8040223726fad1e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=b7d8b6ebcd5dd714bc21acf7637d9a651e2f7ea7

commit b7d8b6ebcd5dd714bc21acf7637d9a651e2f7ea7
Author: Andrew J. Schorr <address@hidden>
Date:   Wed Jun 21 09:57:24 2017 -0400

    Add ezalloc macro in gawk and API to allocate zero-filled memory.

diff --git a/ChangeLog b/ChangeLog
index 086cbe3..233ec4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-19         Andrew J. Schorr     <address@hidden>
+
+       * awk.h (ezalloc): Add new macro to allocate memory initialized to zero.
+       (ezalloc_real): New inline function to call calloc.
+       * gawkapi.h (ezalloc): Add new API macro to allocate memory initialized
+       to zero.
+
 2017-06-18         Arnold D. Robbins     <address@hidden>
 
        * builtin.c (mbc_char_count): Fix code to correctly traverse
diff --git a/awk.h b/awk.h
index ab84c58..d5964f8 100644
--- a/awk.h
+++ b/awk.h
@@ -1331,6 +1331,7 @@ DEREF(NODE *r)
                                __LINE__, __FILE__)
 
 #define        emalloc(var,ty,x,str)   (void) (var = (ty) 
emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__))
+#define        ezalloc(var,ty,x,str)   (void) (var = (ty) 
ezalloc_real((size_t)(x), str, #var, __FILE__, __LINE__))
 #define        erealloc(var,ty,x,str)  (void) (var = (ty) erealloc_real((void 
*) var, (size_t)(x), str, #var, __FILE__, __LINE__))
 
 #define efree(p)       free(p)
@@ -1950,6 +1951,24 @@ emalloc_real(size_t count, const char *where, const char 
*var, const char *file,
        return ret;
 }
 
+/* ezalloc_real --- malloc zero-filled bytes with error checking */
+
+static inline void *
+ezalloc_real(size_t count, const char *where, const char *var, const char 
*file, int line)
+{
+       void *ret;
+
+       if (count == 0)
+               fatal("%s:%d: ezalloc called with zero bytes", file, line);
+
+       ret = (void *) calloc(1, count);
+       if (ret == NULL)
+               fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory 
(%s)"),
+                       file, line, where, var, (long) count, strerror(errno));
+
+       return ret;
+}
+
 /* erealloc_real --- realloc with error checking */
 
 static inline void *
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 9ff5305..39bb693 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-19         Andrew J. Schorr     <address@hidden>
+
+       * gawktexi.in (Memory Allocation Functions and Convenience Macros):
+       Document new ezalloc API macro.
+
 2017-06-18         Andrew J. Schorr     <address@hidden>
 
        * gawkworkflow.texi: Fix typo.
diff --git a/doc/gawk.info b/doc/gawk.info
index 2988fe4..752eec8 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -24009,10 +24009,11 @@ library than was used for the 'gawk' executable.(1)  
If 'gawk' were to
 use its version of 'free()' when the memory came from an unrelated
 version of 'malloc()', unexpected behavior would likely result.
 
-   Two convenience macros may be used for allocating storage from
-'gawk_malloc()' and 'gawk_realloc()'.  If the allocation fails, they
-cause 'gawk' to exit with a fatal error message.  They should be used as
-if they were procedure calls that do not return a value:
+   Three convenience macros may be used for allocating storage from
+'gawk_malloc()', 'gawk_calloc', and 'gawk_realloc()'.  If the allocation
+fails, they cause 'gawk' to exit with a fatal error message.  They
+should be used as if they were procedure calls that do not return a
+value:
 
 '#define emalloc(pointer, type, size, message) ...'
      The arguments to this macro are as follows:
@@ -24041,6 +24042,12 @@ if they were procedure calls that do not return a 
value:
           strcpy(message, greet);
           make_malloced_string(message, strlen(message), & result);
 
+'#define ezalloc(pointer, type, size, message) ...'
+     This is like 'emalloc()', but it calls 'gawk_calloc()' instead of
+     'gawk_malloc()'.  The arguments are the same as for the 'emalloc()'
+     macro, but this macro guarantees that the memory returned is
+     initialized to zero.
+
 '#define erealloc(pointer, type, size, message) ...'
      This is like 'emalloc()', but it calls 'gawk_realloc()' instead of
      'gawk_malloc()'.  The arguments are the same as for the 'emalloc()'
@@ -36183,140 +36190,140 @@ Node: Extension API Functions Introduction961581
 Node: General Data Types966915
 Ref: General Data Types-Footnote-1974120
 Node: Memory Allocation Functions974419
-Ref: Memory Allocation Functions-Footnote-1977264
-Node: Constructor Functions977363
-Node: Registration Functions980362
-Node: Extension Functions981047
-Node: Exit Callback Functions986260
-Node: Extension Version String987510
-Node: Input Parsers988173
-Node: Output Wrappers1000880
-Node: Two-way processors1005392
-Node: Printing Messages1007657
-Ref: Printing Messages-Footnote-11008828
-Node: Updating ERRNO1008981
-Node: Requesting Values1009720
-Ref: table-value-types-returned1010457
-Node: Accessing Parameters1011393
-Node: Symbol Table Access1012628
-Node: Symbol table by name1013140
-Node: Symbol table by cookie1014929
-Ref: Symbol table by cookie-Footnote-11019114
-Node: Cached values1019178
-Ref: Cached values-Footnote-11022714
-Node: Array Manipulation1022805
-Ref: Array Manipulation-Footnote-11023896
-Node: Array Data Types1023933
-Ref: Array Data Types-Footnote-11026591
-Node: Array Functions1026683
-Node: Flattening Arrays1031082
-Node: Creating Arrays1038023
-Node: Redirection API1042792
-Node: Extension API Variables1045634
-Node: Extension Versioning1046267
-Ref: gawk-api-version1046704
-Node: Extension API Informational Variables1048432
-Node: Extension API Boilerplate1049496
-Node: Changes from API V11053358
-Node: Finding Extensions1054018
-Node: Extension Example1054577
-Node: Internal File Description1055375
-Node: Internal File Ops1059455
-Ref: Internal File Ops-Footnote-11070855
-Node: Using Internal File Ops1070995
-Ref: Using Internal File Ops-Footnote-11073378
-Node: Extension Samples1073652
-Node: Extension Sample File Functions1075181
-Node: Extension Sample Fnmatch1082830
-Node: Extension Sample Fork1084317
-Node: Extension Sample Inplace1085535
-Node: Extension Sample Ord1088752
-Node: Extension Sample Readdir1089588
-Ref: table-readdir-file-types1090477
-Node: Extension Sample Revout1091282
-Node: Extension Sample Rev2way1091871
-Node: Extension Sample Read write array1092611
-Node: Extension Sample Readfile1094553
-Node: Extension Sample Time1095648
-Node: Extension Sample API Tests1096996
-Node: gawkextlib1097488
-Node: Extension summary1099935
-Node: Extension Exercises1103637
-Node: Language History1105135
-Node: V7/SVR3.11106791
-Node: SVR41108943
-Node: POSIX1110377
-Node: BTL1111756
-Node: POSIX/GNU1112485
-Node: Feature History1118377
-Node: Common Extensions1132801
-Node: Ranges and Locales1134084
-Ref: Ranges and Locales-Footnote-11138700
-Ref: Ranges and Locales-Footnote-21138727
-Ref: Ranges and Locales-Footnote-31138962
-Node: Contributors1139183
-Node: History summary1144743
-Node: Installation1146123
-Node: Gawk Distribution1147067
-Node: Getting1147551
-Node: Extracting1148512
-Node: Distribution contents1150150
-Node: Unix Installation1156492
-Node: Quick Installation1157174
-Node: Shell Startup Files1159588
-Node: Additional Configuration Options1160677
-Node: Configuration Philosophy1162666
-Node: Non-Unix Installation1165035
-Node: PC Installation1165495
-Node: PC Binary Installation1166333
-Node: PC Compiling1166768
-Node: PC Using1167885
-Node: Cygwin1170930
-Node: MSYS1171700
-Node: VMS Installation1172201
-Node: VMS Compilation1172992
-Ref: VMS Compilation-Footnote-11174221
-Node: VMS Dynamic Extensions1174279
-Node: VMS Installation Details1175964
-Node: VMS Running1178217
-Node: VMS GNV1182496
-Node: VMS Old Gawk1183231
-Node: Bugs1183702
-Node: Bug address1184365
-Node: Usenet1186762
-Node: Maintainers1187539
-Node: Other Versions1188915
-Node: Installation summary1195499
-Node: Notes1196534
-Node: Compatibility Mode1197399
-Node: Additions1198181
-Node: Accessing The Source1199106
-Node: Adding Code1200541
-Node: New Ports1206759
-Node: Derived Files1211247
-Ref: Derived Files-Footnote-11216732
-Ref: Derived Files-Footnote-21216767
-Ref: Derived Files-Footnote-31217365
-Node: Future Extensions1217479
-Node: Implementation Limitations1218137
-Node: Extension Design1219320
-Node: Old Extension Problems1220474
-Ref: Old Extension Problems-Footnote-11221992
-Node: Extension New Mechanism Goals1222049
-Ref: Extension New Mechanism Goals-Footnote-11225413
-Node: Extension Other Design Decisions1225602
-Node: Extension Future Growth1227715
-Node: Old Extension Mechanism1228551
-Node: Notes summary1230314
-Node: Basic Concepts1231496
-Node: Basic High Level1232177
-Ref: figure-general-flow1232459
-Ref: figure-process-flow1233144
-Ref: Basic High Level-Footnote-11236445
-Node: Basic Data Typing1236630
-Node: Glossary1239958
-Node: Copying1271905
-Node: GNU Free Documentation License1309444
-Node: Index1334562
+Ref: Memory Allocation Functions-Footnote-1977571
+Node: Constructor Functions977670
+Node: Registration Functions980669
+Node: Extension Functions981354
+Node: Exit Callback Functions986567
+Node: Extension Version String987817
+Node: Input Parsers988480
+Node: Output Wrappers1001187
+Node: Two-way processors1005699
+Node: Printing Messages1007964
+Ref: Printing Messages-Footnote-11009135
+Node: Updating ERRNO1009288
+Node: Requesting Values1010027
+Ref: table-value-types-returned1010764
+Node: Accessing Parameters1011700
+Node: Symbol Table Access1012935
+Node: Symbol table by name1013447
+Node: Symbol table by cookie1015236
+Ref: Symbol table by cookie-Footnote-11019421
+Node: Cached values1019485
+Ref: Cached values-Footnote-11023021
+Node: Array Manipulation1023112
+Ref: Array Manipulation-Footnote-11024203
+Node: Array Data Types1024240
+Ref: Array Data Types-Footnote-11026898
+Node: Array Functions1026990
+Node: Flattening Arrays1031389
+Node: Creating Arrays1038330
+Node: Redirection API1043099
+Node: Extension API Variables1045941
+Node: Extension Versioning1046574
+Ref: gawk-api-version1047011
+Node: Extension API Informational Variables1048739
+Node: Extension API Boilerplate1049803
+Node: Changes from API V11053665
+Node: Finding Extensions1054325
+Node: Extension Example1054884
+Node: Internal File Description1055682
+Node: Internal File Ops1059762
+Ref: Internal File Ops-Footnote-11071162
+Node: Using Internal File Ops1071302
+Ref: Using Internal File Ops-Footnote-11073685
+Node: Extension Samples1073959
+Node: Extension Sample File Functions1075488
+Node: Extension Sample Fnmatch1083137
+Node: Extension Sample Fork1084624
+Node: Extension Sample Inplace1085842
+Node: Extension Sample Ord1089059
+Node: Extension Sample Readdir1089895
+Ref: table-readdir-file-types1090784
+Node: Extension Sample Revout1091589
+Node: Extension Sample Rev2way1092178
+Node: Extension Sample Read write array1092918
+Node: Extension Sample Readfile1094860
+Node: Extension Sample Time1095955
+Node: Extension Sample API Tests1097303
+Node: gawkextlib1097795
+Node: Extension summary1100242
+Node: Extension Exercises1103944
+Node: Language History1105442
+Node: V7/SVR3.11107098
+Node: SVR41109250
+Node: POSIX1110684
+Node: BTL1112063
+Node: POSIX/GNU1112792
+Node: Feature History1118684
+Node: Common Extensions1133108
+Node: Ranges and Locales1134391
+Ref: Ranges and Locales-Footnote-11139007
+Ref: Ranges and Locales-Footnote-21139034
+Ref: Ranges and Locales-Footnote-31139269
+Node: Contributors1139490
+Node: History summary1145050
+Node: Installation1146430
+Node: Gawk Distribution1147374
+Node: Getting1147858
+Node: Extracting1148819
+Node: Distribution contents1150457
+Node: Unix Installation1156799
+Node: Quick Installation1157481
+Node: Shell Startup Files1159895
+Node: Additional Configuration Options1160984
+Node: Configuration Philosophy1162973
+Node: Non-Unix Installation1165342
+Node: PC Installation1165802
+Node: PC Binary Installation1166640
+Node: PC Compiling1167075
+Node: PC Using1168192
+Node: Cygwin1171237
+Node: MSYS1172007
+Node: VMS Installation1172508
+Node: VMS Compilation1173299
+Ref: VMS Compilation-Footnote-11174528
+Node: VMS Dynamic Extensions1174586
+Node: VMS Installation Details1176271
+Node: VMS Running1178524
+Node: VMS GNV1182803
+Node: VMS Old Gawk1183538
+Node: Bugs1184009
+Node: Bug address1184672
+Node: Usenet1187069
+Node: Maintainers1187846
+Node: Other Versions1189222
+Node: Installation summary1195806
+Node: Notes1196841
+Node: Compatibility Mode1197706
+Node: Additions1198488
+Node: Accessing The Source1199413
+Node: Adding Code1200848
+Node: New Ports1207066
+Node: Derived Files1211554
+Ref: Derived Files-Footnote-11217039
+Ref: Derived Files-Footnote-21217074
+Ref: Derived Files-Footnote-31217672
+Node: Future Extensions1217786
+Node: Implementation Limitations1218444
+Node: Extension Design1219627
+Node: Old Extension Problems1220781
+Ref: Old Extension Problems-Footnote-11222299
+Node: Extension New Mechanism Goals1222356
+Ref: Extension New Mechanism Goals-Footnote-11225720
+Node: Extension Other Design Decisions1225909
+Node: Extension Future Growth1228022
+Node: Old Extension Mechanism1228858
+Node: Notes summary1230621
+Node: Basic Concepts1231803
+Node: Basic High Level1232484
+Ref: figure-general-flow1232766
+Ref: figure-process-flow1233451
+Ref: Basic High Level-Footnote-11236752
+Node: Basic Data Typing1236937
+Node: Glossary1240265
+Node: Copying1272212
+Node: GNU Free Documentation License1309751
+Node: Index1334869
 
 End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 79292a0..afdefff 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -32978,8 +32978,8 @@ to use its version of @code{free()} when the memory 
came from an
 unrelated version of @code{malloc()}, unexpected behavior would
 likely result.
 
-Two convenience macros may be used for allocating storage
-from @code{gawk_malloc()} and
+Three convenience macros may be used for allocating storage
+from @code{gawk_malloc()}, @code{gawk_calloc}, and
 @code{gawk_realloc()}. If the allocation fails, they cause @command{gawk}
 to exit with a fatal error message.  They should be used as if they were
 procedure calls that do not return a value:
@@ -33018,6 +33018,12 @@ strcpy(message, greet);
 make_malloced_string(message, strlen(message), & result);
 @end example
 
address@hidden #define ezalloc(pointer, type, size, message) @dots{}
+This is like @code{emalloc()}, but it calls @code{gawk_calloc()}
+instead of @code{gawk_malloc()}.
+The arguments are the same as for the @code{emalloc()} macro, but this
+macro guarantees that the memory returned is initialized to zero.
+
 @item #define erealloc(pointer, type, size, message) @dots{}
 This is like @code{emalloc()}, but it calls @code{gawk_realloc()}
 instead of @code{gawk_malloc()}.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index e4c9164..7d60a2c 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -31992,8 +31992,8 @@ to use its version of @code{free()} when the memory 
came from an
 unrelated version of @code{malloc()}, unexpected behavior would
 likely result.
 
-Two convenience macros may be used for allocating storage
-from @code{gawk_malloc()} and
+Three convenience macros may be used for allocating storage
+from @code{gawk_malloc()}, @code{gawk_calloc}, and
 @code{gawk_realloc()}. If the allocation fails, they cause @command{gawk}
 to exit with a fatal error message.  They should be used as if they were
 procedure calls that do not return a value:
@@ -32032,6 +32032,12 @@ strcpy(message, greet);
 make_malloced_string(message, strlen(message), & result);
 @end example
 
address@hidden #define ezalloc(pointer, type, size, message) @dots{}
+This is like @code{emalloc()}, but it calls @code{gawk_calloc()}
+instead of @code{gawk_malloc()}.
+The arguments are the same as for the @code{emalloc()} macro, but this
+macro guarantees that the memory returned is initialized to zero.
+
 @item #define erealloc(pointer, type, size, message) @dots{}
 This is like @code{emalloc()}, but it calls @code{gawk_realloc()}
 instead of @code{gawk_malloc()}.
diff --git a/gawkapi.h b/gawkapi.h
index 484ab27..8562b5f 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -878,6 +878,12 @@ typedef struct gawk_api {
                        fatal(ext_id, "%s: malloc of %d bytes failed\n", 
message, size); \
        } while(0)
 
+#define ezalloc(pointer, type, size, message) \
+       do { \
+               if ((pointer = (type) gawk_calloc(1, size)) == 0) \
+                       fatal(ext_id, "%s: calloc of %d bytes failed\n", 
message, size); \
+       } while(0)
+
 #define erealloc(pointer, type, size, message) \
        do { \
                if ((pointer = (type) gawk_realloc(pointer, size)) == 0) \

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog       |   7 ++
 awk.h           |  19 ++++
 doc/ChangeLog   |   5 +
 doc/gawk.info   | 285 +++++++++++++++++++++++++++++---------------------------
 doc/gawk.texi   |  10 +-
 doc/gawktexi.in |  10 +-
 gawkapi.h       |   6 ++
 7 files changed, 199 insertions(+), 143 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]