| 1 |
|
| /* AutoXS::Header version '0.01' */ |
| 2 |
|
| typedef struct { |
| 3 |
|
| U32 hash; |
| 4 |
|
| SV* key; |
| 5 |
|
| } autoxs_hashkey; |
| 6 |
|
| |
| 7 |
|
| unsigned int AutoXS_no_hashkeys = 0; |
| 8 |
|
| unsigned int AutoXS_free_hashkey_no = 0; |
| 9 |
|
| autoxs_hashkey* AutoXS_hashkeys = NULL; |
| 10 |
|
| |
| 11 |
27 |
| unsigned int get_next_hashkey() { |
| 12 |
27 |
▶ | if (AutoXS_no_hashkeys == AutoXS_free_hashkey_no) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (AutoXS_no_hashkeys == AutoXS_free_hashkey_no) { |
10 |
17 |
27 |
|
| 13 |
10 |
| unsigned int extend = 1 + AutoXS_no_hashkeys * 2; |
| 14 |
|
| /*printf("extending hashkey storage by %u\n", extend);*/ |
| 15 |
10 |
| unsigned int oldsize = AutoXS_no_hashkeys * sizeof(autoxs_hashkey); |
| 16 |
|
| /*printf("previous data size %u\n", oldsize);*/ |
| 17 |
|
| autoxs_hashkey* tmphashkeys = |
| 18 |
10 |
| (autoxs_hashkey*) malloc( oldsize + extend * sizeof(autoxs_hashkey) ); |
| 19 |
10 |
| memcpy(tmphashkeys, AutoXS_hashkeys, oldsize); |
| 20 |
10 |
| free(AutoXS_hashkeys); |
| 21 |
10 |
| AutoXS_hashkeys = tmphashkeys; |
| 22 |
10 |
| AutoXS_no_hashkeys += extend; |
| 23 |
|
| } |
| 24 |
27 |
| return AutoXS_free_hashkey_no++; |
| 25 |
|
| } |
| 26 |
|
| |