diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-23 12:14:15 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-10-23 12:14:15 +0300 |
commit | e56b6eabe183ed5fa1352ef0f5f49fb6d894578c (patch) | |
tree | 881ac0a12d947a50e41d2e3e80a0f350aec1d2d3 /str_array.c | |
parent | 2c6c33741890ab08659b7c7ef5b8bc91d487f300 (diff) | |
parent | 3055361c2a022c9ac9ae42ac88c00e3055498a0d (diff) | |
download | egawk-e56b6eabe183ed5fa1352ef0f5f49fb6d894578c.tar.gz egawk-e56b6eabe183ed5fa1352ef0f5f49fb6d894578c.tar.bz2 egawk-e56b6eabe183ed5fa1352ef0f5f49fb6d894578c.zip |
Merge branch 'master' into feature/nocopy
Diffstat (limited to 'str_array.c')
-rw-r--r-- | str_array.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/str_array.c b/str_array.c index e8ce973e..d832380d 100644 --- a/str_array.c +++ b/str_array.c @@ -2,23 +2,23 @@ * str_array.c - routines for associative arrays of string indices. */ -/* +/* * Copyright (C) 1986, 1988, 1989, 1991-2013, 2016, * the Free Software Foundation, Inc. - * + * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. - * + * * GAWK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * GAWK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -126,7 +126,7 @@ str_array_init(NODE *symbol ATTRIBUTE_UNUSED, NODE *subs ATTRIBUTE_UNUSED) * isn't there. Returns a pointer ala get_lhs to where its value is stored. * * SYMBOL is the address of the node (or other pointer) being dereferenced. - * SUBS is a number or string used as the subscript. + * SUBS is a number or string used as the subscript. */ static NODE ** @@ -192,7 +192,7 @@ str_lookup(NODE *symbol, NODE *subs) } subs = tmp; } else { - /* string value already "frozen" */ + /* string value already "frozen" */ subs = dupnode(subs); } @@ -241,7 +241,7 @@ str_clear(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED) r = b->ahvalue; if (r->type == Node_var_array) { assoc_clear(r); /* recursively clear all sub-arrays */ - efree(r->vname); + efree(r->vname); freenode(r); } else unref(r); @@ -318,7 +318,7 @@ str_copy(NODE *symbol, NODE *newsymb) BUCKET **old, **new, **pnew; BUCKET *chain, *newchain; unsigned long cursize, i; - + assert(symbol->table_size > 0); /* find the current hash size */ @@ -364,7 +364,7 @@ str_copy(NODE *symbol, NODE *newsymb) newchain->ahnext = NULL; pnew = & newchain->ahnext; } - } + } newsymb->table_size = symbol->table_size; newsymb->buckets = new; @@ -398,9 +398,9 @@ str_list(NODE *symbol, NODE *t) if ((assoc_kind & (AINDEX|AVALUE|ADELETE)) == (AINDEX|ADELETE)) num_elems = 1; list_size = elem_size * num_elems; - + emalloc(list, NODE **, list_size * sizeof(NODE *), "str_list"); - + /* populate it */ for (i = 0; i < symbol->array_size; i++) { @@ -424,7 +424,7 @@ str_list(NODE *symbol, NODE *t) } if (k >= list_size) return list; - } + } } return list; } @@ -441,7 +441,7 @@ str_kilobytes(NODE *symbol) bucket_cnt = symbol->table_size; /* This does not include extra memory for indices with stfmt != -1 */ - kb = (((AWKNUM) bucket_cnt) * sizeof (BUCKET) + + kb = (((AWKNUM) bucket_cnt) * sizeof (BUCKET) + ((AWKNUM) symbol->array_size) * sizeof (BUCKET *)) / 1024.0; return kb; } @@ -529,7 +529,7 @@ str_dump(NODE *symbol, NODE *ndump) return NULL; #undef HCNT -} +} /* awk_hash --- calculate the hash function of the string in subs */ @@ -642,11 +642,11 @@ grow_table(NODE *symbol) * very large (> 8K), we just double more or less, instead of * just jumping from 8K to 64K. */ - + static const unsigned long sizes[] = { 13, 127, 1021, 8191, 16381, 32749, 65497, 131101, 262147, 524309, 1048583, 2097169, - 4194319, 8388617, 16777259, 33554467, + 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459, 536870923, 1073741827 }; |