dect
/
libdect
Archived
13
0
Fork 0

libdect: support allocating per-handle private space

Similar to other objects, support a private data area for libdect handles
for applications dealing with multiple handles simultenously.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-11-14 18:14:24 +01:00
parent 3c8698333b
commit 582a7d50c7
3 changed files with 13 additions and 1 deletions

View File

@ -127,6 +127,8 @@ struct dect_event_ops {
* The DECT ops contain references to the individual ops of the libdect subsystems.
*/
struct dect_ops {
size_t priv_size;
void *(*malloc)(size_t size);
void (*free)(void *ptr);
@ -144,6 +146,8 @@ extern struct dect_handle *dect_open_handle(struct dect_ops *ops,
const char *cluster);
extern void dect_close_handle(struct dect_handle *dh);
extern void *dect_handle_priv(struct dect_handle *dh);
extern void dect_pp_set_ipui(struct dect_handle *dh,
const struct dect_ipui *ipui);
extern void dect_pp_set_tpui(struct dect_handle *dh,

View File

@ -53,6 +53,8 @@ struct dect_handle {
struct list_head links;
struct list_head mme_list;
uint8_t priv[] __aligned(__alignof__(uint64_t));
};
#endif /* _LIBDECT_H */

View File

@ -31,7 +31,7 @@ static struct dect_handle *dect_alloc_handle(struct dect_ops *ops)
if (ops->free == NULL)
ops->free = free;
dh = ops->malloc(sizeof(*dh));
dh = ops->malloc(sizeof(*dh) + ops->priv_size);
if (dh == NULL)
return NULL;
memset(dh, 0, sizeof(*dh));
@ -92,4 +92,10 @@ void dect_close_handle(struct dect_handle *dh)
}
EXPORT_SYMBOL(dect_close_handle);
void *dect_handle_priv(struct dect_handle *dh)
{
return dh->priv;
}
EXPORT_SYMBOL(dect_handle_priv);
/** @} */