gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, master, updated. gawk-4.1.0-4738-g07d04b91


From: Andrew J. Schorr
Subject: [SCM] gawk branch, master, updated. gawk-4.1.0-4738-g07d04b91
Date: Tue, 7 Jun 2022 09:10:23 -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  07d04b91d1ac3e19fda5e029f1a244ea714c1d13 (commit)
      from  03148f2c29e04e96a26e3728081b18c8bb41b24f (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=07d04b91d1ac3e19fda5e029f1a244ea714c1d13

commit 07d04b91d1ac3e19fda5e029f1a244ea714c1d13
Author: Andrew J. Schorr <aschorr@telemetry-investments.com>
Date:   Tue Jun 7 09:09:28 2022 -0400

    Add a new destroy_array API hook to fix a memory leak in the rwarray 
extension.

diff --git a/ChangeLog b/ChangeLog
index 0ff01ddb..ed536b18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-06-06         Andrew J. Schorr      <aschorr@telemetry-investments.com>
+
+       * gawkapi.h (gawk_api_t): Add new api_destroy_array hook to clear
+       and free an array.
+       (destroy_array): New macro wrapper for api_destroy_array.
+       * gawkapi.c (api_destroy_array): Add new function to clear and free
+       an array.
+       (api_impl): Add hook for api_destroy_array.
+
 2022-06-02         Arnold D. Robbins     <arnold@skeeve.com>
 
        * builtin.c (do_sub): Fix memory corruption when substituting
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 49582469..eee7808f 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2022-06-06         Andrew J. Schorr      <aschorr@telemetry-investments.com>
+
+       * gawktexi.in (Array Functions): Add new function destroy_array.
+
 2022-05-19         Arnold D. Robbins     <arnold@skeeve.com>
 
        * gawktexi.in (Other Versions): Add reference to su8
diff --git a/doc/gawk.info b/doc/gawk.info
index b08c99d1..804caf15 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -27408,6 +27408,12 @@ The following functions relate to individual array 
elements:
      array, but after calling this function, it has no elements.  This
      is equivalent to using the 'delete' statement (*note Delete::).
 
+'awk_bool_t destroy_array(awk_array_t a_cookie);'
+     Clear the array represented by 'a_cookie' and release the array
+     allocated by 'create_array'.  Return false if there was some kind
+     of problem, true otherwise.  The array will no longer exist and
+     cannot be used again.
+
 'awk_bool_t flatten_array_typed(awk_array_t a_cookie,'
 '                               awk_flat_array_t **data,'
 '                               awk_valtype_t index_type,'
@@ -39344,120 +39350,120 @@ Ref: Array Manipulation-Footnote-11108463
 Node: Array Data Types1108500
 Ref: Array Data Types-Footnote-11111158
 Node: Array Functions1111250
-Node: Flattening Arrays1115748
-Node: Creating Arrays1122724
-Node: Redirection API1127491
-Node: Extension API Variables1130324
-Node: Extension Versioning1131035
-Ref: gawk-api-version1131464
-Node: Extension GMP/MPFR Versioning1133196
-Node: Extension API Informational Variables1134824
-Node: Extension API Boilerplate1135897
-Node: Changes from API V11139871
-Node: Finding Extensions1141443
-Node: Extension Example1142002
-Node: Internal File Description1142800
-Node: Internal File Ops1146880
-Ref: Internal File Ops-Footnote-11158230
-Node: Using Internal File Ops1158370
-Ref: Using Internal File Ops-Footnote-11160753
-Node: Extension Samples1161027
-Node: Extension Sample File Functions1162556
-Node: Extension Sample Fnmatch1170205
-Node: Extension Sample Fork1171692
-Node: Extension Sample Inplace1172910
-Node: Extension Sample Ord1176536
-Node: Extension Sample Readdir1177372
-Ref: table-readdir-file-types1178261
-Node: Extension Sample Revout1179329
-Node: Extension Sample Rev2way1179918
-Node: Extension Sample Read write array1180658
-Node: Extension Sample Readfile1183823
-Node: Extension Sample Time1184918
-Node: Extension Sample API Tests1186670
-Node: gawkextlib1187162
-Node: Extension summary1190080
-Node: Extension Exercises1193782
-Node: Language History1195024
-Node: V7/SVR3.11196680
-Node: SVR41198832
-Node: POSIX1200266
-Node: BTL1201647
-Node: POSIX/GNU1202376
-Node: Feature History1208154
-Node: Common Extensions1225329
-Node: Ranges and Locales1226612
-Ref: Ranges and Locales-Footnote-11231228
-Ref: Ranges and Locales-Footnote-21231255
-Ref: Ranges and Locales-Footnote-31231490
-Node: Contributors1231713
-Node: History summary1237710
-Node: Installation1239090
-Node: Gawk Distribution1240034
-Node: Getting1240518
-Node: Extracting1241481
-Node: Distribution contents1243119
-Node: Unix Installation1250180
-Node: Quick Installation1250984
-Node: Compiling with MPFR1253404
-Node: Shell Startup Files1254094
-Node: Additional Configuration Options1255183
-Node: Configuration Philosophy1257498
-Node: Compiling from Git1259894
-Node: Building the Documentation1260449
-Node: Non-Unix Installation1261833
-Node: PC Installation1262293
-Node: PC Binary Installation1263131
-Node: PC Compiling1264004
-Node: PC Using1265121
-Node: Cygwin1268674
-Node: MSYS1269898
-Node: VMS Installation1270500
-Node: VMS Compilation1271219
-Ref: VMS Compilation-Footnote-11272448
-Node: VMS Dynamic Extensions1272506
-Node: VMS Installation Details1274191
-Node: VMS Running1276453
-Node: VMS GNV1280732
-Node: Bugs1281446
-Node: Bug definition1282358
-Node: Bug address1285294
-Node: Usenet1288482
-Node: Performance bugs1289671
-Node: Asking for help1292592
-Node: Maintainers1294559
-Node: Other Versions1295753
-Node: Installation summary1304023
-Node: Notes1305387
-Node: Compatibility Mode1306181
-Node: Additions1306963
-Node: Accessing The Source1307888
-Node: Adding Code1309325
-Node: New Ports1316140
-Node: Derived Files1320515
-Ref: Derived Files-Footnote-11326175
-Ref: Derived Files-Footnote-21326210
-Ref: Derived Files-Footnote-31326808
-Node: Future Extensions1326922
-Node: Implementation Limitations1327580
-Node: Extension Design1328790
-Node: Old Extension Problems1329934
-Ref: Old Extension Problems-Footnote-11331452
-Node: Extension New Mechanism Goals1331509
-Ref: Extension New Mechanism Goals-Footnote-11334873
-Node: Extension Other Design Decisions1335062
-Node: Extension Future Growth1337175
-Node: Notes summary1337781
-Node: Basic Concepts1338939
-Node: Basic High Level1339620
-Ref: figure-general-flow1339902
-Ref: figure-process-flow1340588
-Ref: Basic High Level-Footnote-11343890
-Node: Basic Data Typing1344075
-Node: Glossary1347403
-Node: Copying1379290
-Node: GNU Free Documentation License1416833
-Node: Index1441953
+Node: Flattening Arrays1116035
+Node: Creating Arrays1123011
+Node: Redirection API1127778
+Node: Extension API Variables1130611
+Node: Extension Versioning1131322
+Ref: gawk-api-version1131751
+Node: Extension GMP/MPFR Versioning1133483
+Node: Extension API Informational Variables1135111
+Node: Extension API Boilerplate1136184
+Node: Changes from API V11140158
+Node: Finding Extensions1141730
+Node: Extension Example1142289
+Node: Internal File Description1143087
+Node: Internal File Ops1147167
+Ref: Internal File Ops-Footnote-11158517
+Node: Using Internal File Ops1158657
+Ref: Using Internal File Ops-Footnote-11161040
+Node: Extension Samples1161314
+Node: Extension Sample File Functions1162843
+Node: Extension Sample Fnmatch1170492
+Node: Extension Sample Fork1171979
+Node: Extension Sample Inplace1173197
+Node: Extension Sample Ord1176823
+Node: Extension Sample Readdir1177659
+Ref: table-readdir-file-types1178548
+Node: Extension Sample Revout1179616
+Node: Extension Sample Rev2way1180205
+Node: Extension Sample Read write array1180945
+Node: Extension Sample Readfile1184110
+Node: Extension Sample Time1185205
+Node: Extension Sample API Tests1186957
+Node: gawkextlib1187449
+Node: Extension summary1190367
+Node: Extension Exercises1194069
+Node: Language History1195311
+Node: V7/SVR3.11196967
+Node: SVR41199119
+Node: POSIX1200553
+Node: BTL1201934
+Node: POSIX/GNU1202663
+Node: Feature History1208441
+Node: Common Extensions1225616
+Node: Ranges and Locales1226899
+Ref: Ranges and Locales-Footnote-11231515
+Ref: Ranges and Locales-Footnote-21231542
+Ref: Ranges and Locales-Footnote-31231777
+Node: Contributors1232000
+Node: History summary1237997
+Node: Installation1239377
+Node: Gawk Distribution1240321
+Node: Getting1240805
+Node: Extracting1241768
+Node: Distribution contents1243406
+Node: Unix Installation1250467
+Node: Quick Installation1251271
+Node: Compiling with MPFR1253691
+Node: Shell Startup Files1254381
+Node: Additional Configuration Options1255470
+Node: Configuration Philosophy1257785
+Node: Compiling from Git1260181
+Node: Building the Documentation1260736
+Node: Non-Unix Installation1262120
+Node: PC Installation1262580
+Node: PC Binary Installation1263418
+Node: PC Compiling1264291
+Node: PC Using1265408
+Node: Cygwin1268961
+Node: MSYS1270185
+Node: VMS Installation1270787
+Node: VMS Compilation1271506
+Ref: VMS Compilation-Footnote-11272735
+Node: VMS Dynamic Extensions1272793
+Node: VMS Installation Details1274478
+Node: VMS Running1276740
+Node: VMS GNV1281019
+Node: Bugs1281733
+Node: Bug definition1282645
+Node: Bug address1285581
+Node: Usenet1288769
+Node: Performance bugs1289958
+Node: Asking for help1292879
+Node: Maintainers1294846
+Node: Other Versions1296040
+Node: Installation summary1304310
+Node: Notes1305674
+Node: Compatibility Mode1306468
+Node: Additions1307250
+Node: Accessing The Source1308175
+Node: Adding Code1309612
+Node: New Ports1316427
+Node: Derived Files1320802
+Ref: Derived Files-Footnote-11326462
+Ref: Derived Files-Footnote-21326497
+Ref: Derived Files-Footnote-31327095
+Node: Future Extensions1327209
+Node: Implementation Limitations1327867
+Node: Extension Design1329077
+Node: Old Extension Problems1330221
+Ref: Old Extension Problems-Footnote-11331739
+Node: Extension New Mechanism Goals1331796
+Ref: Extension New Mechanism Goals-Footnote-11335160
+Node: Extension Other Design Decisions1335349
+Node: Extension Future Growth1337462
+Node: Notes summary1338068
+Node: Basic Concepts1339226
+Node: Basic High Level1339907
+Ref: figure-general-flow1340189
+Ref: figure-process-flow1340875
+Ref: Basic High Level-Footnote-11344177
+Node: Basic Data Typing1344362
+Node: Glossary1347690
+Node: Copying1379577
+Node: GNU Free Documentation License1417120
+Node: Index1442240
 
 End Tag Table
 
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 00d9647d..d5d3651f 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -37742,6 +37742,12 @@ The array remains an array, but after calling this 
function, it
 has no elements. This is equivalent to using the @code{delete}
 statement (@pxref{Delete}).
 
+@item awk_bool_t destroy_array(awk_array_t a_cookie);
+Clear the array represented by @code{a_cookie} and release the array
+allocated by @code{create_array}.
+Return false if there was some kind of problem, true otherwise.
+The array will no longer exist and cannot be used again.
+
 @item awk_bool_t flatten_array_typed(awk_array_t a_cookie,
 @itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 
awk_flat_array_t **data,
 @itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 
awk_valtype_t index_type,
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 8f0f6740..198f3700 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -36585,6 +36585,12 @@ The array remains an array, but after calling this 
function, it
 has no elements. This is equivalent to using the @code{delete}
 statement (@pxref{Delete}).
 
+@item awk_bool_t destroy_array(awk_array_t a_cookie);
+Clear the array represented by @code{a_cookie} and release the array
+allocated by @code{create_array}.
+Return false if there was some kind of problem, true otherwise.
+The array will no longer exist and cannot be used again.
+
 @item awk_bool_t flatten_array_typed(awk_array_t a_cookie,
 @itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 
awk_flat_array_t **data,
 @itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 
awk_valtype_t index_type,
diff --git a/extension/ChangeLog b/extension/ChangeLog
index c6d0fae5..03cfa145 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,9 @@
+2022-06-06         Andrew J. Schorr      <aschorr@telemetry-investments.com>
+
+       * rwarray.c (free_value): For arrays, we actually need to call
+       the new API function destroy_array to release the allocated NODE,
+       rather than clear_array.
+
 2022-06-01         Arnold D. Robbins     <arnold@skeeve.com>
 
        * rwarray.c: Add ifdefs for MPFR in a few places that were
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 92e8ddd2..c016cd0d 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -409,7 +409,7 @@ free_value(awk_value_t *v)
 {
        switch (v->val_type) {
        case AWK_ARRAY:
-               clear_array(v->array_cookie);
+               destroy_array(v->array_cookie);
                break;
        case AWK_STRING:
        case AWK_REGEX:
diff --git a/gawkapi.c b/gawkapi.c
index 90f328f8..01157d52 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -1204,6 +1204,17 @@ api_clear_array(awk_ext_id_t id, awk_array_t a_cookie)
        return awk_true;
 }
 
+/* api_destroy_array --- destroy an array */
+
+static awk_bool_t
+api_destroy_array(awk_ext_id_t id, awk_array_t a_cookie)
+{
+       if (! api_clear_array(id, a_cookie))
+               return awk_false;
+       freenode((NODE *) a_cookie);
+       return awk_true;
+}
+
 /* api_flatten_array_typed --- flatten out an array so that it can be looped 
over easily. */
 
 static awk_bool_t
@@ -1561,6 +1572,9 @@ gawk_api_t api_impl = {
 
        /* Find/open a file */
        api_get_file,
+
+       /* Additional array hook to destroy an array */
+       api_destroy_array,
 };
 
 /* init_ext_api --- init the extension API */
diff --git a/gawkapi.h b/gawkapi.h
index 69dd843f..825ec3dd 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -846,6 +846,9 @@ typedef struct gawk_api {
                         */
                        const awk_input_buf_t **ibufp,
                        const awk_output_buf_t **obufp);
+
+       /* Destroy an array. */
+       awk_bool_t (*api_destroy_array)(awk_ext_id_t id, awk_array_t a_cookie);
 } gawk_api_t;
 
 #ifndef GAWK   /* these are not for the gawk code itself! */
@@ -916,6 +919,8 @@ typedef struct gawk_api {
 
 #define create_array()         (api->api_create_array(ext_id))
 
+#define destroy_array(array)   (api->api_destroy_array(ext_id, array))
+
 #define clear_array(array)     (api->api_clear_array(ext_id, array))
 
 #define flatten_array_typed(array, data, index_type, value_type) \

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

Summary of changes:
 ChangeLog           |   9 ++
 doc/ChangeLog       |   4 +
 doc/gawk.info       | 234 +++++++++++++++++++++++++++-------------------------
 doc/gawk.texi       |   6 ++
 doc/gawktexi.in     |   6 ++
 extension/ChangeLog |   6 ++
 extension/rwarray.c |   2 +-
 gawkapi.c           |  14 ++++
 gawkapi.h           |   5 ++
 9 files changed, 171 insertions(+), 115 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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