diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-02-12 11:23:59 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-02-12 11:23:59 +0000 |
commit | aed09e72d81b7e4cad62a1477ea348a29e901ffc (patch) | |
tree | e1f3869f40f8037ecdd0704bb86f629a33343ee4 /TODO | |
parent | f3d72251d93baeb4a50b42c48889040e90c7bf16 (diff) | |
download | mpfr-aed09e72d81b7e4cad62a1477ea348a29e901ffc.tar.gz |
[TODO] + Serialization / Deserialization (suggested by Frédéric Pétrot).
I've also added an idea of implementation to reuse most of the code and
change very little.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13705 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'TODO')
-rw-r--r-- | TODO | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -304,6 +304,51 @@ Table of contents: Text from: https://www.zsh.org/mla/workers/2019/msg01138.html +- Serialization / Deserialization. Suggested by Frédéric Pétrot: + https://sympa.inria.fr/sympa/arc/mpfr/2020-02/msg00006.html + like mpfr_fpif_{import,export}, but with memory instead of file. + + Idea of implementation to reuse most of the code and change very little: + + Instead of passing a FILE *fh, pass a struct ext_data *h, and instead of + using fread and fwrite, use + h->read (h, buffer, size) + h->write (h, buffer, size) + respectively. + + The struct ext_data structure could contain the following fields: + * read: pointer to a wrapper function for the read method. + * write: pointer to a wrapper function for the write method. + * FILE *hf: to be used for operations with files. + * unsigned char *arena: to be used for operations with memory. + + The wrapper functions for the read method could be: + + static int + read_from_file (struct ext_data *h, unsigned char *buffer, size_t size) + { + return fread (buffer, size, 1, h->fh) != 1; + } + + static int + read_from_memory (struct ext_data *h, unsigned char *buffer, size_t size) + { + if (f->arena == NULL) + return 1; + memcpy (buffer, f->arena, size); + f->arena += size; + return 0; + } + + So I expect very few changes in the existing code: + * Write a few wrapper functions. + * Rename mpfr_fpif_export to mpfr_fpif_export_aux and + mpfr_fpif_import to mpfr_fpif_import_aux. + * In the existing functions, replace FILE *fh, and fread/fwrite + calls as mentioned above. + * Add new mpfr_fpif_export, mpfr_fpif_import, mpfr_fpif_export_mem, + mpfr_fpif_import_mem. + ############################################################################## 5. Efficiency ############################################################################## |