Lines Matching refs:ctx
124 static idn_result_t addrange(idn_ucsset_t ctx, unsigned long from,
129 idn_ucsset_create(idn_ucsset_t *ctx) {
132 assert(ctx != NULL);
144 *ctx = bm;
149 idn_ucsset_destroy(idn_ucsset_t ctx) {
150 assert(ctx != NULL && ctx->refcnt > 0);
154 if (--ctx->refcnt == 0) {
155 if (ctx->ranges != NULL)
156 free(ctx->ranges);
157 free(ctx);
162 idn_ucsset_incrref(idn_ucsset_t ctx) {
163 assert(ctx != NULL && ctx->refcnt > 0);
167 ctx->refcnt++;
171 idn_ucsset_add(idn_ucsset_t ctx, unsigned long v) {
172 assert(ctx != NULL && ctx->refcnt > 0);
176 return (addrange(ctx, v, v, "idn_ucsset_add"));
180 idn_ucsset_addrange(idn_ucsset_t ctx, unsigned long from,
183 assert(ctx != NULL && ctx->refcnt > 0);
188 return (addrange(ctx, from, to, "idn_ucsset_addrange"));
192 idn_ucsset_fix(idn_ucsset_t ctx) {
198 assert(ctx != NULL && ctx->refcnt > 0);
202 nranges = ctx->nranges;
203 ranges = ctx->ranges;
204 segments = ctx->segments;
206 if (ctx->fixed)
209 ctx->fixed = 1;
238 ctx->nranges = nranges = ++i;
258 ctx->ranges = realloc(ctx->ranges, ctx->nranges * sizeof(range_t));
263 idn_ucsset_lookup(idn_ucsset_t ctx, unsigned long v, int *found) {
267 assert(ctx != NULL && ctx->refcnt > 0 && found != NULL);
272 if (!ctx->fixed) {
282 segments = ctx->segments;
290 range_t *ranges = ctx->ranges;
308 addrange(idn_ucsset_t ctx, unsigned long from, unsigned long to,
329 if (ctx->fixed) {
336 if (ctx->nranges >= ctx->size) {
338 if (ctx->size == 0)
339 ctx->size = INIT_SIZE;
341 ctx->size *= 2;
342 newbuf = realloc(ctx->ranges, ctx->size * sizeof(range_t));
345 ctx->ranges = newbuf;
347 ctx->ranges[ctx->nranges].from = from;
348 ctx->ranges[ctx->nranges].to = to;
349 ctx->nranges++;