Skip to content

What does fmemopen() do in file format readers? #1023

@szhorvat

Description

@szhorvat

If HAVE_FMEMOPEN is defined, the file format readers make use of fmemopen(). Example:

rigraph/src/rinterface_extra.c

Lines 6423 to 6427 in 323f1b4

#if HAVE_FMEMOPEN == 1
file=fmemopen(RAW(pvfile), Rf_xlength(pvfile), "r");
#else
file=fopen(CHAR(STRING_ELT(pvfile, 0)), "r");
#endif

  • Is this code correct at all? It seems to me that depending on this macro, pvfile is interpreter either as the contents of a file, or a file name. These are not interchangeable.
  • If this code is present, why are we not making use of HAVE_FMEMOPEN?

This needs to be reviewed by someone familiar with R internals and R's facilities to treat strings as files. Can we make use of this and gain better performance when parsing contents of strings?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions