Documentation - C API
generic.c File Reference

Generic - Definition. More...

#include "generic.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <Windows.h>
#include <unistd.h>

Functions

char const * vl_get_version_string ()
 Get version string.
char * vl_configuration_to_string_copy ()
 Human readable library configuration.
static int do_nothing_printf (char const *format,...)
 A printf that does not do anything.
void vl_lock_state ()
 Lock VLFeat state.
void vl_unlock_state ()
 Unlock VLFeat state.
int vl_set_last_error (int error, char const *errorMessage,...)
 Set last VLFeat error.
void vl_set_alloc_func (void *(*malloc_func)(size_t), void *(*realloc_func)(void *, size_t), void *(*calloc_func)(size_t, size_t), void(*free_func)(void *))
 Set memory allocation functions.
void vl_set_printf_func (printf_func_t printf_func)
 Set printf function.
double vl_get_cpu_time ()
 Get processor time.
void vl_tic ()
 Reset processor time reference The function resets VLFeat TIC/TOC time reference.
double vl_toc ()
 Get elapsed time since tic.
VlRandvl_get_rand ()
 Get the random number generator for this thread.
static void vl_constructor ()
 Initialize VLFeat.
static void vl_destructor ()
 Destruct VLFeat.

Variables

VlState _vl_state

Detailed Description

Author:
Andrea Vedaldi

Function Documentation

static int do_nothing_printf ( char const *  format,
  ... 
) [static]
char* vl_configuration_to_string_copy ( )
Returns:
a new string with the library configuration.

The function returns a new string with a human readable rendition of the library configuration.

static void vl_constructor ( ) [static]
static void vl_destructor ( ) [static]
double vl_get_cpu_time ( )
Returns:
processor time.
See also:
vl_tic, vl_toc
VlRand* vl_get_rand ( )
Returns:
random number generator.

The function returns a pointer to the random number genrator for this thread.

char const* vl_get_version_string ( )
Returns:
library version string
void vl_lock_state ( )

The function locks VLFeat global state mutex.

The mutex is recursive: locking multiple times from the same thread is a valid operations, but requires an equivalent number of calls to vl_unlock_state.

See also:
vl_unlock_state
void vl_set_alloc_func ( void *(*)(size_t)  malloc_func,
void *(*)(void *, size_t)  realloc_func,
void *(*)(size_t, size_t)  calloc_func,
void(*)(void *)  free_func 
)
Parameters:
malloc_funcpointer to malloc.
realloc_funcpointer to realloc.
calloc_funcpointer to calloc.
free_funcpointer to free.
int vl_set_last_error ( int  error,
char const *  errorMessage,
  ... 
)

The function sets the code and optionally the error message of the last encountered error. errorMessage is the message format. It uses the printf convention and is followed by the format arguments. The maximum lenght of the error message is given by VL_ERR_MSG_LEN (longer messages are truncated).

Passing NULL as errorMessage sets the error message to the empty string.

Parameters:
errorerror code.
errorMessageerror message format string.
...format string arguments.
Returns:
error code.
void vl_set_printf_func ( printf_func_t  printf_func)
Parameters:
printf_funcpointer to printf. Let print_func be NULL to disable printf.
void vl_tic ( )
See also:
vl_get_cpu_time, vl_toc.
double vl_toc ( )

The function returns the processor time elapsed since vl_tic was called last.

Remarks:
In multi-threaded applications, there is an independent timer for each execution thread.
On UNIX, this function uses the clock() system call. On Windows, it uses the QueryPerformanceCounter() system call, which is more accurate than clock() on this platform.
Returns:
elapsed time in seconds.
void vl_unlock_state ( )

The function unlocks VLFeat global state mutex.

See also:
vl_lock_state

Variable Documentation

---------------------------------------------------------------