~andreas-pokorny/platform-api/opaque_by_default

« back to all changes in this revision

Viewing changes to src/ubuntu/hybris/bridge.h

  • Committer: Andreas Pokorny
  • Date: 2014-02-17 22:41:29 UTC
  • mfrom: (190.1.2 platform-api)
  • Revision ID: andreas.pokorny@canonical.com-20140217224129-086bn5nh3rv84y3r
[ Martin Pitt ]
Fix crash in ua_sensors_*_new() if there is no available backend.
Return NULL instead. (LP: #1272294)

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
/**********************************************************/
115
115
 
116
116
#define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<>::instance().resolve_symbol(sym); }
117
 
    
 
117
 
 
118
// this allows DLSYM to return NULL (happens if the backend is not available),
 
119
// and returns NULL in that case; return_type must be a pointer!
 
120
#define IMPLEMENT_CTOR0(return_type, symbol)  \
 
121
    return_type symbol()                          \
 
122
    {                                             \
 
123
        static return_type (*f)() = NULL;         \
 
124
        DLSYM(&f, #symbol);                       \
 
125
        return f ? f() : NULL;}
 
126
 
118
127
#define IMPLEMENT_FUNCTION0(return_type, symbol)  \
119
128
    return_type symbol()                          \
120
129
    {                                             \
128
137
        static void (*f)() = NULL;                \
129
138
        DLSYM(&f, #symbol);                       \
130
139
        f();}
131
 
    
 
140
 
132
141
#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \
133
142
    return_type symbol(arg1 _1)                        \
134
143
    {                                                  \