unsigned int crc32_add_byte(unsigned int checksum, unsigned char b)
{
- if(!crc32)
- crc32_init();
+ crc32_init();
return checksum>>8 ^ crc32[(b^checksum)&0xff];
}
unsigned int crc32_add_string(unsigned int checksum, const char*s)
{
- if(!crc32)
- crc32_init();
+ crc32_init();
if(!s)
return checksum;
while(*s) {
{
int t;
unsigned int checksum = 0;
- if(!crc32)
- crc32_init();
+ crc32_init();
for(t=0;t<str->len;t++) {
checksum = checksum>>8 ^ crc32[(str->str[t]^checksum)&0xff];
}
{
unsigned int checksum = 0;
const char*p = str;
- if(!crc32)
- crc32_init();
+ crc32_init();
while(*p) {
checksum = checksum>>8 ^ crc32[(*p^checksum)&0xff];
p++;
return 0;
}
+char dict_del2(dict_t*h, const void*key, void*data)
+{
+ if(!h->num)
+ return 0;
+ unsigned int hash = h->key_type->hash(key) % h->hashsize;
+ dictentry_t*head = h->slots[hash];
+ dictentry_t*e = head, *prev=0;
+ while(e) {
+ if(h->key_type->equals(e->key, key) && e->data == data) {
+ dictentry_t*next = e->next;
+ h->key_type->free(e->key);
+ memset(e, 0, sizeof(dictentry_t));
+ rfx_free(e);
+ if(e == head) {
+ h->slots[hash] = next;
+ } else {
+ assert(prev);
+ prev->next = next;
+ }
+ h->num--;
+ return 1;
+ }
+ prev = e;
+ e = e->next;
+ }
+ return 0;
+}
+
dictentry_t* dict_get_slot(dict_t*h, const void*key)
{
if(!h->num)
}
void*array_getkey(array_t*array, int nr) {
if(nr > array->num || nr<0) {
- printf("error: reference to element %d in array[%d]\n", nr, array->num);
+ fprintf(stderr, "error: reference to element %d in array[%d]\n", nr, array->num);
return 0;
}
return array->d[nr].name;
}
void*array_getvalue(array_t*array, int nr) {
if(nr > array->num || nr<0) {
- printf("error: reference to element %d in array[%d]\n", nr, array->num);
+ fprintf(stderr, "error: reference to element %d in array[%d]\n", nr, array->num);
return 0;
}
return array->d[nr].data;