14.07.2013 Views

PBC Library Manual 0.5.11 - Stanford Crypto Group

PBC Library Manual 0.5.11 - Stanford Crypto Group

PBC Library Manual 0.5.11 - Stanford Crypto Group

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Selects a random bits-bit integer z.<br />

6.2. Custom allocation<br />

Chapter 6. Other functions<br />

Like GMP, <strong>PBC</strong> can be instructed to use custom memory allocation functions. This must be done before<br />

any memory allocation is performed, usually at the beginning of a program before any other <strong>PBC</strong><br />

functions have been called.<br />

Also like GMP, the <strong>PBC</strong> wrappers around malloc and realloc will print a message on standard error<br />

and terminate program execution if the calls fail. Replacements for these functions should act similarly.<br />

However, unlike GMP, <strong>PBC</strong> does not pass the number of bytes previously allocated along with the<br />

pointer in calls to realloc and free.<br />

void pbc_set_memory_functions(void *(*malloc_fn)(size_t), void *(*realloc_fn)(void *, size_t), void<br />

(*free_fn)(void *))<br />

6.3. Logging<br />

Set custom allocation functions. The parameters must be function pointers to drop-in replacements for malloc,<br />

realloc and free, except that malloc and realloc should terminate the program on failure: they must not return in<br />

this case.<br />

int pbc_set_msg_to_stderr(int i)<br />

By default error messages are printed to standard error. Call pbc_set_msg_to_stderr(0) to suppress<br />

messages.<br />

void pbc_die(const char *err, . . . )<br />

Reports error message and exits with code 128.<br />

void pbc_info(const char *err, . . . )<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!