~ubuntu-branches/ubuntu/intrepid/m4/intrepid

« back to all changes in this revision

Viewing changes to lib/malloca.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2008-04-03 09:49:04 UTC
  • mfrom: (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080403094904-nzbg2ojnfh38cog0
Tags: 1.4.11-1
* New upstream release.
* Changed copyright file to refer to the GFDL in common-licenses.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
   This program is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
7
 
   the Free Software Foundation; either version 2, or (at your option)
 
7
   the Free Software Foundation; either version 3, or (at your option)
8
8
   any later version.
9
9
 
10
10
   This program is distributed in the hope that it will be useful,
70
70
# define freea free
71
71
#endif
72
72
 
73
 
/* Maybe we should also define a variant
74
 
    nmalloca (size_t n, size_t s) - behaves like malloca (n * s)
75
 
   If this would be useful in your application. please speak up.  */
 
73
/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
 
74
   It allocates an array of N objects, each with S bytes of memory,
 
75
   on the stack.  S must be positive and N must be nonnegative.
 
76
   The array must be freed using freea() before the function returns.  */
 
77
#if 1
 
78
/* Cf. the definition of xalloc_oversized.  */
 
79
# define nmalloca(n, s) \
 
80
    ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
 
81
     ? NULL \
 
82
     : malloca ((n) * (s)))
 
83
#else
 
84
extern void * nmalloca (size_t n, size_t s);
 
85
#endif
76
86
 
77
87
 
78
88
#ifdef __cplusplus