IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4368


Ignore:
Timestamp:
Jun 23, 2005, 11:19:45 AM (21 years ago)
Author:
Paul Price
Message:

Clarified policy on signed/unsigned for memory allocation; psAlloc checks the allocation size against PS_MEM_LIMIT

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/ChangeLogSDRS.tex

    r4365 r4368  
    1 %%% $Id: ChangeLogSDRS.tex,v 1.151 2005-06-23 03:06:32 price Exp $
     1%%% $Id: ChangeLogSDRS.tex,v 1.152 2005-06-23 21:19:45 price Exp $
    22
    33\subsection{Changes from version 00 to version 01}
     
    736736\item Added \code{psArrayElementsFree} (already implemented).
    737737\item \code{psMask} changed to \code{psMaskType} (more clear).
    738 \item Use the \code{region} in \code{psImageTransform} to set the size of the output image (bug 453).
    739 \item \code{list} in \code{psListIteratorAlloc} is not const (bug 455).
    740 \end{itemize}
     738\item Use the \code{region} in \code{psImageTransform} to set the size
     739  of the output image (bug 453).
     740\item \code{list} in \code{psListIteratorAlloc} is not const (bug
     741  455).
     742\item Clarified policy on signed/unsigned for memory allocation;
     743  \code{psAlloc} checks the allocation size against
     744  \code{PS_MEM_LIMIT}.
     745\end{itemize}
  • trunk/doc/pslib/psLibSDRS.tex

    r4365 r4368  
    1 %%% $Id: psLibSDRS.tex,v 1.294 2005-06-23 03:06:32 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.295 2005-06-23 21:19:45 price Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    547547\code{NULL}.  If no free function is set, \code{psMemGetDeallocator}
    548548shall return \code{NULL}.
     549
     550\paragraph{Negative allocations}
     551
     552Note that we have specified that the memory size is unsigned
     553(\code{size_t}), so that we can address the full range of memory that
     554the architecture will allow, and to match the behaviour of the system
     555\code{malloc}.  This creates the potential for problems if a negative
     556value is inadvertently passed to \code{psAlloc} --- it will be
     557interpreted as a very large positive value.  To guard against this, we
     558specify that \code{psAlloc} must check that the allocation is less
     559than \code{PS_MEM_LIMIT} (a preprocessor variable).
     560
     561For array-like collections (specifically, \code{psArray},
     562\code{psVector}, and \code{psImage}) we allow the user to refer to a
     563negative index to mean address from the end.  Consequently, the number
     564of elements in structures should be signed.  It is the responsibility
     565of these structure allocators (e.g., \code{psArrayAlloc}) to check
     566that the requested number of elements is not negative (calling
     567\code{psAbort} otherwise).  All other allocators shall simply use
     568size_t where the number of elements is needed (saving the trouble of
     569checking before passing to psAlloc).
    549570
    550571\subsubsection{Callback Routines}
Note: See TracChangeset for help on using the changeset viewer.