Asterisk - The Open Source Telephony Project GIT-master-a358458
Functions
astobj2_global.c File Reference

Functions implementing ao2_global_obj routines. More...

#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/utils.h"
Include dependency graph for astobj2_global.c:

Go to the source code of this file.

Functions

void * __ao2_global_obj_ref (struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
 
void * __ao2_global_obj_replace (struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
 
int __ao2_global_obj_replace_unref (struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
 

Detailed Description

Functions implementing ao2_global_obj routines.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file astobj2_global.c.

Function Documentation

◆ __ao2_global_obj_ref()

void * __ao2_global_obj_ref ( struct ao2_global_obj holder,
const char *  tag,
const char *  file,
int  line,
const char *  func,
const char *  name 
)

Definition at line 72 of file astobj2_global.c.

73{
74 void *obj;
75
76 if (!holder) {
77 /* For sanity */
78 ast_log(LOG_ERROR, "Must be called with a global object!\n");
79 ast_assert(0);
80 return NULL;
81 }
82
83 if (__ast_rwlock_rdlock(file, line, func, &holder->lock, name)) {
84 /* Could not get the read lock. */
85 ast_assert(0);
86 return NULL;
87 }
88
89 obj = holder->obj;
90 if (obj) {
91 __ao2_ref(obj, +1, tag, file, line, func);
92 }
93
94 __ast_rwlock_unlock(file, line, func, &holder->lock, name);
95
96 return obj;
97}
#define ast_log
Definition: astobj2.c:42
int __ao2_ref(void *o, int delta, const char *tag, const char *file, int line, const char *func)
Definition: astobj2.c:498
static const char name[]
Definition: format_mp3.c:68
#define LOG_ERROR
int __ast_rwlock_unlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
Definition: lock.c:777
int __ast_rwlock_rdlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
Definition: lock.c:848
#define NULL
Definition: resample.c:96
void * obj
Definition: astobj2.h:807
ast_rwlock_t lock
Definition: astobj2.h:805
#define ast_assert(a)
Definition: utils.h:739

References __ao2_ref(), __ast_rwlock_rdlock(), __ast_rwlock_unlock(), ast_assert, ast_log, make_ari_stubs::file, ao2_global_obj::lock, LOG_ERROR, name, NULL, and ao2_global_obj::obj.

◆ __ao2_global_obj_replace()

void * __ao2_global_obj_replace ( struct ao2_global_obj holder,
void *  obj,
const char *  tag,
const char *  file,
int  line,
const char *  func,
const char *  name 
)

Definition at line 33 of file astobj2_global.c.

34{
35 void *obj_old;
36
37 if (!holder) {
38 /* For sanity */
39 ast_log(LOG_ERROR, "Must be called with a global object!\n");
40 ast_assert(0);
41 return NULL;
42 }
43 if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) {
44 /* Could not get the write lock. */
45 ast_assert(0);
46 return NULL;
47 }
48
49 if (obj) {
50 __ao2_ref(obj, +1, tag, file, line, func);
51 }
52 obj_old = holder->obj;
53 holder->obj = obj;
54
55 __ast_rwlock_unlock(file, line, func, &holder->lock, name);
56
57 return obj_old;
58}
int __ast_rwlock_wrlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name)
Definition: lock.c:952

References __ao2_ref(), __ast_rwlock_unlock(), __ast_rwlock_wrlock(), ast_assert, ast_log, make_ari_stubs::file, ao2_global_obj::lock, LOG_ERROR, name, NULL, and ao2_global_obj::obj.

Referenced by __ao2_global_obj_replace_unref().

◆ __ao2_global_obj_replace_unref()

int __ao2_global_obj_replace_unref ( struct ao2_global_obj holder,
void *  obj,
const char *  tag,
const char *  file,
int  line,
const char *  func,
const char *  name 
)

Definition at line 60 of file astobj2_global.c.

61{
62 void *obj_old;
63
64 obj_old = __ao2_global_obj_replace(holder, obj, tag, file, line, func, name);
65 if (obj_old) {
66 __ao2_ref(obj_old, -1, tag, file, line, func);
67 return 1;
68 }
69 return 0;
70}
void * __ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)

References __ao2_global_obj_replace(), __ao2_ref(), make_ari_stubs::file, and name.