Back to index

tetex-bin  3.0
Defines | Functions
xsize.h File Reference
#include <stddef.h>
#include <limits.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define xcast_size_t(N)   ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
#define xtimes(N, ELSIZE)   ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
#define size_overflow_p(SIZE)   ((SIZE) == SIZE_MAX)
#define size_in_bounds_p(SIZE)   ((SIZE) != SIZE_MAX)

Functions

static size_t xsum (size_t size1, size_t size2)
static size_t xsum3 (size_t size1, size_t size2, size_t size3)
static size_t xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
static size_t xmax (size_t size1, size_t size2)

Define Documentation

#define size_in_bounds_p (   SIZE)    ((SIZE) != SIZE_MAX)

Definition at line 106 of file xsize.h.

#define size_overflow_p (   SIZE)    ((SIZE) == SIZE_MAX)

Definition at line 103 of file xsize.h.

#define xcast_size_t (   N)    ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)

Definition at line 49 of file xsize.h.

#define xtimes (   N,
  ELSIZE 
)    ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)

Definition at line 99 of file xsize.h.


Function Documentation

static size_t xmax ( size_t  size1,
size_t  size2 
) [inline, static]

Definition at line 88 of file xsize.h.

{
  /* No explicit check is needed here, because for any n:
     max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */
  return (size1 >= size2 ? size1 : size2);
}

Here is the caller graph for this function:

static size_t xsum ( size_t  size1,
size_t  size2 
) [inline, static]

Definition at line 57 of file xsize.h.

{
  size_t sum = size1 + size2;
  return (sum >= size1 ? sum : SIZE_MAX);
}

Here is the caller graph for this function:

static size_t xsum3 ( size_t  size1,
size_t  size2,
size_t  size3 
) [inline, static]

Definition at line 68 of file xsize.h.

{
  return xsum (xsum (size1, size2), size3);
}

Here is the call graph for this function:

static size_t xsum4 ( size_t  size1,
size_t  size2,
size_t  size3,
size_t  size4 
) [inline, static]

Definition at line 78 of file xsize.h.

{
  return xsum (xsum (xsum (size1, size2), size3), size4);
}

Here is the call graph for this function:

Here is the caller graph for this function: