refobject.h 1.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2018,      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
 */

#ifndef __REFOBJECT_H__
#define __REFOBJECT_H__

#include "common/thread/thread.h"

#include "icecasttypes.h"
#include "compat.h"

17
typedef void (*refobject_free_t)(refobject_t self, void **userdata);
18 19 20 21 22

struct refobject_base_tag {
    size_t refc;
    mutex_t lock;
    void *userdata;
23 24 25
    refobject_free_t freecb;
    char *name;
    refobject_t parent;
26 27
};

28
refobject_t     refobject_new(size_t len, refobject_free_t freecb, void *userdata, const char *name, refobject_t parent);
29 30 31 32
int             refobject_ref(refobject_t self);
int             refobject_unref(refobject_t self);
void *          refobject_get_userdata(refobject_t self);
int             refobject_set_userdata(refobject_t self, void *userdata);
33 34
const char *    refobject_get_name(refobject_t self);
refobject_t     refobject_get_parent(refobject_t self);
35 36

#endif