


MEMALLOC(3)     PEKS 0.8.16 Programming Interface     MEMALLOC(3)


NNAAMMEE
       pmalloc, vmalloc, smalloc - allocate classified memory
       preclassify vreclassify sreclassify - reclassify memory
       set_memblock_max,  xrealloc,  xfree - administrate classi-
       fied memory

SSYYNNOOPPSSIISS
       ##iinncclluuddee <<ppeekkss..hh>>

       vvooiidd **ppmmaalllloocc ((ssiizzee__tt _s_i_z_e)),,
            **vvmmaalllloocc ((ssiizzee__tt _s_i_z_e)),,
            **ssmmaalllloocc ((ssiizzee__tt _s_i_z_e));;

       vvooiidd pprreeccllaassssiiffyy ((vvooiidd **_m_e_m___p_t_r)),,
            vvrreeccllaassssiiffyy ((vvooiidd **_m_e_m___p_t_r)),,
            ssrreeccllaassssiiffyy ((vvooiidd **_m_e_m___p_t_r));;

       uunnssiiggnneedd sseett__mmeemmbblloocckk__mmaaxx ((ssiizzee__tt _m_a_x___s_i_z_e));;

       vvooiidd **xxrreeaalllloocc ((vvooiidd **_m_e_m___p_t_r,, ssiizzee__tt _n_e_w___s_i_z_e));;

       vvooiidd xxffrreeee ((vvooiidd **_m_e_m___p_t_r));;

DDEESSCCRRIIPPTTIIOONN
       The functions here provide a substitute for  the  standard
       dynamic  memory  functions mmaalllloocc(()), ccaalllloocc(()), ffrreeee(()), and
       rreeaalllloocc(()).  Although based on  those  functions,  the  new
       memory  functions _m_u_s_t _n_o_t be intermixed with them:  allo-
       cating memory with ppmmaalllloocc(()) and freeing  it  with  ffrreeee(())
       (or  vv.)   results in undefined system behavior and leads
       most certainly to a program crash.

       Classified memory as allocated with ppmmaalllloocc(()),  vvmmaalllloocc(()),
       end  ssmmaalllloocc(())  comes  in three flavours: ppublic, privvate,
       and ssecure. All memory allocated by any of the  classified
       memory functions is zero-initialized.  The allocator func-
       tions accept 0 as a valid _s_i_z_e argument.

       Public memory allocated with ppmmaalllloocc(()) is the  same  zero-
       initialized  memory  type  ccaalllloocc(()) would return, as well.
       The only difference is, that  it  cannot  be  reclassified
       (using vvrreeccllaassssiiffyy(()) for instance) and must be deallocated
       with ffrreeee(()) instad of xxffrreeee(()).

       Private memory allocated with ppmmaalllloocc(())  is  zero-initial-
       ized  and will be overwritten in xxffrreeee(()) before given back
       to the operating system.

       Secure memory allocated with ssmmaalllloocc(()) is handled  similar
       to private memory but will be overwritten with random data
       when deallocated in xxffrreeee(()).

       The functions pprreeccllaassssiiffyy(()), vvrreeccllaassssiiffyy(()),  and  ssrreeccllaass--
       ssiiffyy(())  reschedule  the  clean  up procedure in xxffrreeee(()) to



PEKS CIPHER LAYER          Nov 07, 2000                         1





MEMALLOC(3)     PEKS 0.8.16 Programming Interface     MEMALLOC(3)


       work as ppublic, privvate, or ssecure.  Argument is a  memory
       pointer  as  returned  from any of the allocator functions
       (for instance ppmmaalllloocc(())) for classified memory.

       With xxrreeaalllloocc(()), a memory block already allocated will  be
       changed,   or  reallocated.   When  the  memory  block  is
       extended, the new part will be zero-initialized,  when  it
       is  shrunk,  the  deallocated  part  will be treated as in
       xxffrreeee(()). The re-allocator function accepts 0  as  a  valid
       _n_e_w___s_i_z_e argument.

       All  functions  that return a memory pointer will not work
       with sizes larger than an implementation dependent default
       value,  currently  1MBytes.  With  the  function  sseett__mmeemm--
       bblloocckk__mmaaxx(()) this maximal block size can be  increased,  or
       decreased. Function argument _m_a_x___s_i_z_e is the new limit, to
       be suggested.

RREETTUURRNN VVAALLUUEE
       All functions that return  a  memory  pointer  will  never
       return  NULL.   A  condition  that  would result in a NULL
       pointer causes the program to abort.

       The function sseett__mmeemmbblloocckk__mmaaxx(()) returns the  size  of  the
       maximal  data block that could be allocated when the func-
       tion was invoked.

CCAAVVEEAATT
       Using xxmmaalllloocc(()) for a non-public memory block will  _a_l_w_a_y_s
       return a new memory area while the old one is freed.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       HHOOMMEE   The path to the user's home directory.

SSEEEE AALLSSOO
       mmaalllloocc(3), ccaalllloocc(3), ffrreeee(3), rreeaalllloocc(3)

AAUUTTHHOORR
       The ppeekkss package where these functions belong to was writ-
       ten by Jordan Hrycaj <jordan@teddy-net.com>, originally to
       support the nneessssuuss security scanner.
















PEKS CIPHER LAYER          Nov 07, 2000                         2


