Global Lender
A Pebble app for finding new and interesting loans on kiva.org
Macros | Functions
misc.h File Reference
#include "libs/magpebapp.h"
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HEAP_LOG_0()   APP_LOG(APP_LOG_LEVEL_DEBUG, "Free Heap: %zu b, Used Heap: %zu b", heap_bytes_free(), heap_bytes_used())
 Prints the free and used heap sizes to the app log, with or without an additional c-string argument to append. More...
 
#define HEAP_LOG_1(str)   if (str != NULL) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Free Heap: %zu b, Used Heap: %zu b -- %s", heap_bytes_free(), heap_bytes_used(), str); }
 
#define GET_MACRO(_0, _1, NAME, ...)   NAME
 
#define HEAP_LOG(...)   GET_MACRO(_0, ##__VA_ARGS__, HEAP_LOG_1, HEAP_LOG_0)(__VA_ARGS__)
 
#define strxlen(str)   (str==NULL?0:strlen(str))
 Returns the length of the specified string, or 0 if NULL. More...
 

Functions

void textLayer_stylize (TextLayer *, const GColor, const GColor, const GTextAlignment, const GFont)
 Stylizes the text layer to the spec. More...
 
bool strxcpy (char *buffer, size_t bufsize, const char *source, const char *readable)
 Copies a string with error handling and logging. More...
 
MagPebApp_ErrCode strxcpyalloc (char **dest, const char *src)
 

Macro Definition Documentation

#define GET_MACRO (   _0,
  _1,
  NAME,
  ... 
)    NAME
#define HEAP_LOG (   ...)    GET_MACRO(_0, ##__VA_ARGS__, HEAP_LOG_1, HEAP_LOG_0)(__VA_ARGS__)
#define HEAP_LOG_0 ( )    APP_LOG(APP_LOG_LEVEL_DEBUG, "Free Heap: %zu b, Used Heap: %zu b", heap_bytes_free(), heap_bytes_used())

Prints the free and used heap sizes to the app log, with or without an additional c-string argument to append.

#define HEAP_LOG_1 (   str)    if (str != NULL) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Free Heap: %zu b, Used Heap: %zu b -- %s", heap_bytes_free(), heap_bytes_used(), str); }
#define strxlen (   str)    (str==NULL?0:strlen(str))

Returns the length of the specified string, or 0 if NULL.

Function Documentation

bool strxcpy ( char *  buffer,
size_t  bufsize,
const char *  source,
const char *  readable 
)

Copies a string with error handling and logging.

MagPebApp_ErrCode strxcpyalloc ( char **  dest,
const char *  src 
)

Copies a string from src to dest, where these strings may be NULL or allocated, and (*dest) will result in a NULL or will be allocated to fit the src string.

  • If (*dest) is NULL, it will malloc'd to an appropriate size to contain the string in src.
  • If (*dest) is non-NULL, it will be realloc'd to an appropriate size to contain the string in src.
  • If src is NULL, then (*dest) will be freed and made NULL (or dest will remain NULL if it is already NULL.
Parameters
[in]srcThe source string. May be NULL, or it may be a previously-allocated string, or a string literal. If it is a string, it must be null-terminated.
[in,out]destPointer to the destination char*. The char* may be NULL, or it may be a previously-allocated string. If it is a string, it must be null-terminated upon entry. Upon exit, the char* pointed to by dest is guaranteed to be either NULL or null-terminated. If the char* pointed to by dest is not NULL on exit, then the caller is responsible for freeing it.
Returns
MPA_SUCCESS on success MPA_NULL_POINTER_ERR if the dest double-pointer is NULL. MPA_OUT_OF_MEMORY_ERR if memory could not be allocated for dest
void textLayer_stylize ( TextLayer *  ,
const GColor  ,
const GColor  ,
const GTextAlignment  ,
const GFont   
)

Stylizes the text layer to the spec.