Browse Source

replace calloc in hash/value.c with quick fit approach

release0.1.5
Georg Hopp 12 years ago
parent
commit
672515ae85
  1. 8
      src/hash/value.c

8
src/hash/value.c

@ -45,14 +45,14 @@ hashValueCtor(void * _this, va_list * params)
value = va_arg(* params, void*); value = va_arg(* params, void*);
this->nvalue = va_arg(* params, size_t); this->nvalue = va_arg(* params, size_t);
this->key = malloc(this->nkey + 1);
this->key = memMalloc(this->nkey + 1);
this->key[this->nkey] = 0; this->key[this->nkey] = 0;
memcpy(this->key, key, this->nkey); memcpy(this->key, key, this->nkey);
this->hash = sdbm((unsigned char *)this->key, this->nkey); this->hash = sdbm((unsigned char *)this->key, this->nkey);
if (NULL != value) { if (NULL != value) {
this->value = malloc(this->nvalue + 1);
this->value = memMalloc(this->nvalue + 1);
((char*)this->value)[this->nvalue] = 0; ((char*)this->value)[this->nvalue] = 0;
memcpy(this->value, value, this->nvalue); memcpy(this->value, value, this->nvalue);
} }
@ -66,8 +66,8 @@ hashValueDtor(void * _this)
{ {
HashValue this = _this; HashValue this = _this;
FREE(this->key);
FREE(this->value);
MEM_FREE(this->key);
MEM_FREE(this->value);
} }
static static

Loading…
Cancel
Save