]> jfr.im git - solanum.git/blobdiff - ircd/capability.c
Add tests for valid_temp_time
[solanum.git] / ircd / capability.c
index 2eb5c60e7ecd40d3d6332b5ee3f7158877fb522f..710bce106b63e1bfb7e50d34ef600267327debbf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 William Pitcock <nenolod@dereferenced.org>.
+ * Copyright (c) 2012 Ariadne Conill <ariadne@dereferenced.org>.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -67,11 +67,16 @@ capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata)
        if ((entry = rb_dictionary_retrieve(idx->cap_dict, cap)) != NULL)
        {
                entry->flags &= ~CAP_ORPHANED;
+               if (ownerdata != NULL)
+               {
+                       s_assert(entry->ownerdata == NULL);
+                       entry->ownerdata = ownerdata;
+               }
                return (1 << entry->value);
        }
 
        entry = rb_malloc(sizeof(struct CapabilityEntry));
-       entry->cap = cap;
+       entry->cap = rb_strdup(cap);
        entry->flags = 0;
        entry->value = idx->highest_bit;
        entry->ownerdata = ownerdata;
@@ -133,7 +138,9 @@ capability_destroy(rb_dictionary_element *delem, void *privdata)
 {
        s_assert(delem != NULL);
 
-       rb_free(delem->data);
+       struct CapabilityEntry *entry = delem->data;
+       rb_free((char *)entry->cap);
+       rb_free(entry);
 }
 
 struct CapabilityIndex *
@@ -143,7 +150,7 @@ capability_index_create(const char *name)
 
        idx = rb_malloc(sizeof(struct CapabilityIndex));
        idx->name = name;
-       idx->cap_dict = rb_dictionary_create(name, strcasecmp);
+       idx->cap_dict = rb_dictionary_create(name, rb_strcasecmp);
        idx->highest_bit = 1;
 
        rb_dlinkAdd(idx, &idx->node, &capability_indexes);