MCPcopy Create free account
hub / github.com/creatale/node-dv / boxaaWriteMem

Function boxaaWriteMem

deps/leptonica/src/boxbasic.c:2045–2083  ·  view source on GitHub ↗

! * \brief boxaaWriteMem() * * \param[out] pdata data of serialized boxaa; ascii * \param[out] psize size of returned data * \param[in] baa * \return 0 if OK, 1 on error * * * Notes: * (1) Serializes a boxaa in memory and puts the result in a buffer. * */

Source from the content-addressed store, hash-verified

2043 * </pre>
2044 */
2045l_int32
2046boxaaWriteMem(l_uint8 **pdata,
2047 size_t *psize,
2048 BOXAA *baa)
2049{
2050l_int32 ret;
2051FILE *fp;
2052
2053 PROCNAME("boxaaWriteMem");
2054
2055 if (pdata) *pdata = NULL;
2056 if (psize) *psize = 0;
2057 if (!pdata)
2058 return ERROR_INT("&data not defined", procName, 1);
2059 if (!psize)
2060 return ERROR_INT("&size not defined", procName, 1);
2061 if (!baa)
2062 return ERROR_INT("baa not defined", procName, 1);
2063
2064#if HAVE_FMEMOPEN
2065 if ((fp = open_memstream((char **)pdata, psize)) == NULL)
2066 return ERROR_INT("stream not opened", procName, 1);
2067 ret = boxaaWriteStream(fp, baa);
2068#else
2069 L_INFO("work-around: writing to a temp file\n", procName);
2070 #ifdef _WIN32
2071 if ((fp = fopenWriteWinTempfile()) == NULL)
2072 return ERROR_INT("tmpfile stream not opened", procName, 1);
2073 #else
2074 if ((fp = tmpfile()) == NULL)
2075 return ERROR_INT("tmpfile stream not opened", procName, 1);
2076 #endif /* _WIN32 */
2077 ret = boxaaWriteStream(fp, baa);
2078 rewind(fp);
2079 *pdata = l_binaryReadStream(fp, psize);
2080#endif /* HAVE_FMEMOPEN */
2081 fclose(fp);
2082 return ret;
2083}
2084
2085
2086/*---------------------------------------------------------------------*

Callers

nothing calls this directly

Calls 3

boxaaWriteStreamFunction · 0.85
fopenWriteWinTempfileFunction · 0.85
l_binaryReadStreamFunction · 0.85

Tested by

no test coverage detected