Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| SHA1 Hash: | f0275d44a69f704f1dfcb04f9f55e5c19d425413 |
|---|---|
| Date: | 2009-06-08 20:52:17 |
| User: | stephan |
| Comment: | constness updates |
Tags And Properties
- branch=trunk inherited from [2bd6172b61]
- sym-trunk inherited from [2bd6172b61]
Changes
Changes to whrc.c
| Old (2e21d9d2ad366f20) | New (b69d6c6c75b73999) | |||
|---|---|---|---|---|
| 1 | #include <stdlib.h> /* malloc/free */ | 1 | #include <stdlib.h> /* malloc/free */ | |
| 2 | #include <assert.h> | 2 | #include <assert.h> | |
| 3 | 3 | |||
| 4 | #include "whrc.h" | 4 | #include "whrc.h" | |
| 5 | #include "whhash.h" | 5 | #include "whhash.h" | |
| 140 hidden lines | ||||
| 146 | bool whrc_is_registered( whrc_context * cx, void const * item ) | 146 | bool whrc_is_registered( whrc_context * cx, void const * item ) | |
| 147 | { | 147 | { | |
| 148 | return 0 != whrc_search_entry(cx,item); | 148 | return 0 != whrc_search_entry(cx,item); | |
| 149 | } | 149 | } | |
| 150 | 150 | |||
| 151 | static whrc_entry * whrc_take_entry( whrc_context * cx, void * item ) | | | 151 | static whrc_entry * whrc_take_entry( whrc_context * cx, void const * item ) |
| 152 | { | 152 | { | |
| 153 | return cx | 153 | return cx | |
| 154 | ? (whrc_entry *) whhash_take(cx->ht, item) | 154 | ? (whrc_entry *) whhash_take(cx->ht, item) | |
| 155 | : 0; | 155 | : 0; | |
| 156 | } | 156 | } | |
| 157 | 157 | |||
| 158 | size_t whrc_addref( whrc_context * cx, void * item ) | | | 158 | size_t whrc_addref( whrc_context * cx, void const * item ) |
| 159 | { | 159 | { | |
| 160 | whrc_entry * e = whrc_search_entry(cx,item); | 160 | whrc_entry * e = whrc_search_entry(cx,item); | |
| 161 | if( ! e ) return whrc_ref_err_val; | 161 | if( ! e ) return whrc_ref_err_val; | |
| 162 | return ++e->refcount; | 162 | return ++e->refcount; | |
| 163 | } | 163 | } | |
| 25 hidden lines | ||||
| 189 | } | 189 | } | |
| 190 | 190 | |||
| 191 | #ifdef __cplusplus | 191 | #ifdef __cplusplus | |
| 192 | } /* extern "C" */ | 192 | } /* extern "C" */ | |
| 193 | #endif | 193 | #endif | |
Changes to whrc.h
| Old (a16dc9ab135125fb) | New (232b793e1694d515) | |||
|---|---|---|---|---|
| 1 | #ifndef WANDERINGHORSE_NET_WHRC_H_INCLUDED | 1 | #ifndef WANDERINGHORSE_NET_WHRC_H_INCLUDED | |
| 2 | #define WANDERINGHORSE_NET_WHRC_H_INCLUDED 1 | 2 | #define WANDERINGHORSE_NET_WHRC_H_INCLUDED 1 | |
| 3 | /** @page whrc_page_main whrc: reference counting library for C | 3 | /** @page whrc_page_main whrc: reference counting library for C | |
| 4 | 4 | |||
| 5 | whrc (the WanderingHorse.net Reference Counter) is a C library for | 5 | whrc (the WanderingHorse.net Reference Counter) is a C library for | |
| 131 hidden lines | ||||
| 137 | /** | 137 | /** | |
| 138 | Adds one to the reference count of item and returns the new | 138 | Adds one to the reference count of item and returns the new | |
| 139 | reference count, or whrc_ref_err_val if (!cx), (!item), or | 139 | reference count, or whrc_ref_err_val if (!cx), (!item), or | |
| 140 | if no entry is found. | 140 | if no entry is found. | |
| 141 | */ | 141 | */ | |
| 142 | size_t whrc_addref( whrc_context * cx, void * item ); | | | 142 | size_t whrc_addref( whrc_context * cx, void const * item ); |
| 143 | 143 | |||
| 144 | /** | 144 | /** | |
| 145 | Subtracts one to the reference count of item and returns the new | 145 | Subtracts one to the reference count of item and returns the new | |
| 146 | reference count, or whrc_ref_err_val if (!cx) or (!item), or | 146 | reference count, or whrc_ref_err_val if (!cx) or (!item), or | |
| 147 | if no entry is found. If 0 is returned then the dtor registered | 147 | if no entry is found. If 0 is returned then the dtor registered | |
| 148 | via whrc_register() is called and passed item. | | | 148 | via whrc_register() is called and passed item. After calling this, |
| | | 149 | client code should behave as-if item has been destroyed (and it | ||
| | | 150 | will be if the refcount goes to 0). | ||
| 149 | */ | 151 | */ | |
| 150 | size_t whrc_rmref( whrc_context * cx, void * item ); | 152 | size_t whrc_rmref( whrc_context * cx, void * item ); | |
| 151 | 153 | |||
| 152 | /** | 154 | /** | |
| 153 | Returns the current refcount for the given item, or whrc_ref_err_val | 155 | Returns the current refcount for the given item, or whrc_ref_err_val | |
| 6 hidden lines | ||||
| 160 | } /* extern "C" */ | 162 | } /* extern "C" */ | |
| 161 | #endif | 163 | #endif | |
| 162 | 164 | |||
| 163 | 165 | |||
| 164 | #endif /* WANDERINGHORSE_NET_WHRC_H_INCLUDED */ | 166 | #endif /* WANDERINGHORSE_NET_WHRC_H_INCLUDED */ | |