Linear Methods for Image Interpolation
Functions
basic.c File Reference

Memory management, portable types, math constants, and timing. More...

#include <stdlib.h>
#include <stdarg.h>
#include "basic.h"
#include <time.h>
Include dependency graph for basic.c:

Go to the source code of this file.

Functions

unsigned long Clock ()
 Time in milliseconds, useful for measuring elapsed time.
void * MallocWithErrorMessage (size_t Size)
 malloc with an error message on failure.
void * ReallocWithErrorMessage (void *Ptr, size_t Size)
 realloc with an error message and free on failure.
void ErrorMessage (const char *Format,...)
 Redefine this function to customize error messages.

Detailed Description

Memory management, portable types, math constants, and timing.

Author:
Pascal Getreuer <getreuer@gmail.com>

This file implements a function Clock, a timer with millisecond precision. In order to obtain timing at high resolution, platform- specific functions are needed:

Otherwise as a fallback, time.h time is used, and in this case Clock has only second accuracy. This file attempts to detect whether the platform is POSIX or Windows and defines Clock accordingly. A particular implementation can be forced by defining USE_GETSYSTEMTIME, USE_GETTIMEOFDAY, or USE_TIME.

Copyright (c) 2010-2011, Pascal Getreuer All rights reserved.

This program is free software: you can use, modify and/or redistribute it under the terms of the simplified BSD License. You should have received a copy of this license along this program. If not, see <http://www.opensource.org/licenses/bsd-license.html>.

Definition in file basic.c.


Function Documentation

unsigned long Clock ( )

Time in milliseconds, useful for measuring elapsed time.

Returns:
Number of milliseconds since an arbitrary point

This routine obtains the system time with millisecond precision. There is no portable ANSI C millisecond timer, so Clock is defined depending on the platform. On POSIX systems, Clock uses gettimeofday. Otherwise, if the system is Windows, GetSystemTime is used. If the system is neither POSIX nor Windows, the low-resolution time.h clock function is used as a fallback.

Use this function as

     unsigned long Start, Stop;
     Start = Clock();
     BigComputation();
     Stop = Clock();
     printf("Elapsed time: %.3f\n", 0.001f*(Stop - Start));

Definition at line 75 of file basic.c.

Here is the caller graph for this function:

void ErrorMessage ( const char *  Format,
  ... 
)

Redefine this function to customize error messages.

Definition at line 117 of file basic.c.

Here is the caller graph for this function:

void* MallocWithErrorMessage ( size_t  Size)

malloc with an error message on failure.

Definition at line 90 of file basic.c.

Here is the call graph for this function:

void* ReallocWithErrorMessage ( void *  Ptr,
size_t  Size 
)

realloc with an error message and free on failure.

Definition at line 102 of file basic.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines