libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
Macros | Functions | Variables
core.h File Reference
#include <stdlib.h>
#include "libconfig.h"
Include dependency graph for core.h:

Go to the source code of this file.

Macros

#define UNUSED_ATTR
 
#define WARN_UNUSED_RES_ATTR
 
#define PACKED_ATTR
 
#define DEPRECATED_ATTR
 
#define UNUSED(x)   (void)(x)
 
#define LACF_UNUSED(x)   (void)(x)
 
#define NODISCARD   WARN_UNUSED_RES_ATTR
 
#define NODISCARD_R(reason)   WARN_UNUSED_RES_ATTR
 
#define ACFSYM(__sym__)   __libacfutils_ ## __sym__
 
#define API_EXPORT
 
#define API_EXPORT_DATA   extern
 
#define restrict
 
#define inline
 
#define LACF_DESTROY(ptr)
 
#define ARRAY_NUM_ELEM(_array)   (sizeof (_array) / sizeof (*(_array)))
 

Functions

void * lacf_malloc (size_t n)
 
void lacf_free (void *buf)
 

Variables

const char * libacfutils_version
 

Macro Definition Documentation

◆ ACFSYM

#define ACFSYM (   __sym__)    __libacfutils_ ## __sym__

Definition at line 116 of file core.h.

◆ API_EXPORT

#define API_EXPORT

Definition at line 126 of file core.h.

◆ API_EXPORT_DATA

#define API_EXPORT_DATA   extern

Definition at line 127 of file core.h.

◆ ARRAY_NUM_ELEM

#define ARRAY_NUM_ELEM (   _array)    (sizeof (_array) / sizeof (*(_array)))

Given a fixed-size array, evaluates to the number of elements in the array. Useful for automatically determining the capacity of an array for functions which take a count-of-elements argument.

Definition at line 171 of file core.h.

◆ DEPRECATED_ATTR

#define DEPRECATED_ATTR

Definition at line 98 of file core.h.

◆ inline

#define inline

Definition at line 150 of file core.h.

◆ LACF_DESTROY

#define LACF_DESTROY (   ptr)
Value:
do { \
if ((ptr) != NULL) { \
lacf_free((ptr)); \
(ptr) = NULL; \
} \
} while (0)

Calls lacf_free() on ptr and also then sets the pointer to NULL to force a null-pointer-dereference and hard crash if an attempt is made to use the pointer after the LACF_DESTROY operation.

Definition at line 158 of file core.h.

◆ LACF_UNUSED

#define LACF_UNUSED (   x)    (void)(x)

Definition at line 106 of file core.h.

◆ NODISCARD

#define NODISCARD   WARN_UNUSED_RES_ATTR

Definition at line 112 of file core.h.

◆ NODISCARD_R

#define NODISCARD_R (   reason)    WARN_UNUSED_RES_ATTR

Definition at line 113 of file core.h.

◆ PACKED_ATTR

#define PACKED_ATTR

Attribute which marks a structure as having a packed memory layout (i.e. the compiler isn't allowed to insert padding). Place at the start of a structure definition, e.g. PACKED_ATTR struct structName { ... };

Definition at line 97 of file core.h.

◆ restrict

#define restrict

Definition at line 143 of file core.h.

◆ UNUSED

#define UNUSED (   x)    (void)(x)

Attribute which stops a compiler from complaining when a variable isn't used.

Definition at line 103 of file core.h.

◆ UNUSED_ATTR

#define UNUSED_ATTR

Attribute which marks a function as unused. This is designed to avoid warnings & errors from compiler code analyzers for unused static functions. Place this ahead of a function declaration or definition, to mark the function as purposely unused.

Definition at line 95 of file core.h.

◆ WARN_UNUSED_RES_ATTR

#define WARN_UNUSED_RES_ATTR

Attribute which if used on a function, makes the compiler emit a warning if the return value of a function is ignored.

Definition at line 96 of file core.h.

Function Documentation

◆ lacf_free()

void lacf_free ( void *  buf)

Whenever libacfutils returns an allocated object (except for the safe_*alloc functions) that you must free, use lacf_free to do so. Otherwise you risk running into troubles with different allocators being used between compilers (thanks Windows!).

Definition at line 49 of file core.c.

◆ lacf_malloc()

void * lacf_malloc ( size_t  n)

Allocates ‘n’ bytes of memory using libacfutils' allocator. This is mostly to complete the functionality of ‘lacf_free’. In general, you won't ever need to call this function.

Definition at line 37 of file core.c.

Variable Documentation

◆ libacfutils_version

const char* libacfutils_version
extern

A string holding the current build version of libacfutils. It's just a 7-character git revision number.

Definition at line 29 of file core.c.