diff -r 0dbdd7e8c1fc -r 88092b88ec00 ucx/map.c --- a/ucx/map.c Fri Dec 12 15:48:54 2014 +0100 +++ b/ucx/map.c Mon Dec 15 09:57:35 2014 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2013 Olaf Wintermann. All rights reserved. + * Copyright 2014 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -44,18 +44,16 @@ allocator = ucx_default_allocator(); } - UcxMap *map = (UcxMap*)allocator->malloc(allocator->pool, sizeof(UcxMap)); + UcxMap *map = (UcxMap*)almalloc(allocator, sizeof(UcxMap)); if (!map) { return NULL; } map->allocator = allocator; - map->map = (UcxMapElement**)allocator->calloc( - allocator->pool, - size, - sizeof(UcxMapElement*)); + map->map = (UcxMapElement**)alcalloc( + allocator, size, sizeof(UcxMapElement*)); if(map->map == NULL) { - allocator->free(allocator->pool, map); + alfree(allocator, map); return NULL; } map->size = size; @@ -70,18 +68,18 @@ if (elem != NULL) { do { UcxMapElement *next = elem->next; - map->allocator->free(map->allocator->pool, elem->key.data); - map->allocator->free(map->allocator->pool, elem); + alfree(map->allocator, elem->key.data); + alfree(map->allocator, elem); elem = next; } while (elem != NULL); } } - map->allocator->free(map->allocator->pool, map->map); + alfree(map->allocator, map->map); } void ucx_map_free(UcxMap *map) { ucx_map_free_elmlist(map); - map->allocator->free(map->allocator->pool, map); + alfree(map->allocator, map); } int ucx_map_copy(UcxMap *restrict from, UcxMap *restrict to, @@ -116,10 +114,8 @@ oldmap.allocator = map->allocator; map->size = (map->count * 5) >> 1; - map->map = (UcxMapElement**)map->allocator->calloc( - map->allocator->pool, - map->size, - sizeof(UcxMapElement*)); + map->map = (UcxMapElement**)alcalloc( + map->allocator, map->size, sizeof(UcxMapElement*)); if (!map->map) { *map = oldmap; return 1; @@ -150,9 +146,8 @@ } if (!elm || elm->key.hash != key.hash) { - UcxMapElement *e = (UcxMapElement*)allocator->malloc( - allocator->pool, - sizeof(UcxMapElement)); + UcxMapElement *e = (UcxMapElement*)almalloc( + allocator, sizeof(UcxMapElement)); if (!e) { return -1; } @@ -167,7 +162,7 @@ } if (!elm->key.data) { - void *kd = allocator->malloc(allocator->pool, key.len); + void *kd = almalloc(allocator, key.len); if (!kd) { return -1; } @@ -200,8 +195,8 @@ } else { map->map[slot] = elm->next; } - map->allocator->free(map->allocator->pool, elm->key.data); - map->allocator->free(map->allocator->pool, elm); + alfree(map->allocator, elm->key.data); + alfree(map->allocator, elm); map->count--; }