… | |
… | |
109 | if (expect_true (next_gc > 0)) |
109 | if (expect_true (next_gc > 0)) |
110 | return; |
110 | return; |
111 | |
111 | |
112 | static const char *curpos; |
112 | static const char *curpos; |
113 | |
113 | |
114 | auto (i, curpos ? ht.find (curpos) : ht.begin ()); |
114 | auto i = curpos ? ht.find (curpos) : ht.begin (); |
115 | |
115 | |
116 | if (i == ht.end ()) |
116 | if (i == ht.end ()) |
117 | i = ht.begin (); |
117 | i = ht.begin (); |
118 | |
118 | |
119 | int n = ht.size () / 256 + 16; |
119 | int n = ht.size () / 256 + 16; |
… | |
… | |
128 | } |
128 | } |
129 | else if (!--n) |
129 | else if (!--n) |
130 | break; |
130 | break; |
131 | else if (!refcnt (*i)) |
131 | else if (!refcnt (*i)) |
132 | { |
132 | { |
133 | auto (o, i++); |
|
|
134 | const char *s = *o; |
133 | const char *s = *i; |
135 | |
134 | |
136 | ht.erase (o); |
135 | i = ht.erase (i); |
137 | |
136 | |
138 | //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s)); |
137 | //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s)); |
139 | int alloc = sizeof (uint32_t) * NUM_INT + length (s) + 1; |
138 | int alloc = sizeof (uint32_t) * NUM_INT + length (s) + 1; |
140 | shstr_alloc -= alloc; |
139 | shstr_alloc -= alloc; |
141 | g_slice_free1 (alloc, (void *)(s - sizeof (uint32_t) * NUM_INT)); |
140 | g_slice_free1 (alloc, (void *)(s - sizeof (uint32_t) * NUM_INT)); |