csecp256k1

Haskell FFI bindings to bitcoin-core/secp256k1 (docs.ppad.tech/csecp256k1).
git clone git://git.ppad.tech/csecp256k1.git
Log | Files | Refs | README | LICENSE

scratch.h (2460B)


      1 /***********************************************************************
      2  * Copyright (c) 2017 Andrew Poelstra                                  *
      3  * Distributed under the MIT software license, see the accompanying    *
      4  * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
      5  ***********************************************************************/
      6 
      7 #ifndef SECP256K1_SCRATCH_H
      8 #define SECP256K1_SCRATCH_H
      9 
     10 /* The typedef is used internally; the struct name is used in the public API
     11  * (where it is exposed as a different typedef) */
     12 typedef struct haskellsecp256k1_v0_1_0_scratch_space_struct {
     13     /** guard against interpreting this object as other types */
     14     unsigned char magic[8];
     15     /** actual allocated data */
     16     void *data;
     17     /** amount that has been allocated (i.e. `data + offset` is the next
     18      *  available pointer)  */
     19     size_t alloc_size;
     20     /** maximum size available to allocate */
     21     size_t max_size;
     22 } haskellsecp256k1_v0_1_0_scratch;
     23 
     24 static haskellsecp256k1_v0_1_0_scratch* haskellsecp256k1_v0_1_0_scratch_create(const haskellsecp256k1_v0_1_0_callback* error_callback, size_t max_size);
     25 
     26 static void haskellsecp256k1_v0_1_0_scratch_destroy(const haskellsecp256k1_v0_1_0_callback* error_callback, haskellsecp256k1_v0_1_0_scratch* scratch);
     27 
     28 /** Returns an opaque object used to "checkpoint" a scratch space. Used
     29  *  with `haskellsecp256k1_v0_1_0_scratch_apply_checkpoint` to undo allocations. */
     30 static size_t haskellsecp256k1_v0_1_0_scratch_checkpoint(const haskellsecp256k1_v0_1_0_callback* error_callback, const haskellsecp256k1_v0_1_0_scratch* scratch);
     31 
     32 /** Applies a check point received from `haskellsecp256k1_v0_1_0_scratch_checkpoint`,
     33  *  undoing all allocations since that point. */
     34 static void haskellsecp256k1_v0_1_0_scratch_apply_checkpoint(const haskellsecp256k1_v0_1_0_callback* error_callback, haskellsecp256k1_v0_1_0_scratch* scratch, size_t checkpoint);
     35 
     36 /** Returns the maximum allocation the scratch space will allow */
     37 static size_t haskellsecp256k1_v0_1_0_scratch_max_allocation(const haskellsecp256k1_v0_1_0_callback* error_callback, const haskellsecp256k1_v0_1_0_scratch* scratch, size_t n_objects);
     38 
     39 /** Returns a pointer into the most recently allocated frame, or NULL if there is insufficient available space */
     40 static void *haskellsecp256k1_v0_1_0_scratch_alloc(const haskellsecp256k1_v0_1_0_callback* error_callback, haskellsecp256k1_v0_1_0_scratch* scratch, size_t n);
     41 
     42 #endif