Save work on loading object dictionaries - have a memory issue someplace.

This commit is contained in:
Michael R Sweet
2021-05-04 21:31:58 -04:00
parent 7afdfc725c
commit 4abb91ca24
8 changed files with 139 additions and 38 deletions

View File

@ -67,10 +67,16 @@ _pdfioObjDelete(pdfio_obj_t *obj) // I - Object
pdfio_dict_t * // O - Dictionary or `NULL` on error
pdfioObjGetDict(pdfio_obj_t *obj) // I - Object
{
// TODO: Implement me
(void)obj;
if (!obj)
return (NULL);
return (NULL);
if (obj->value.type == PDFIO_VALTYPE_NONE)
_pdfioObjLoad(obj);
if (obj->value.type == PDFIO_VALTYPE_DICT)
return (obj->value.value.dict);
else
return (NULL);
}
@ -103,29 +109,18 @@ pdfioObjGetNumber(pdfio_obj_t *obj) // I - Object
const char * // O - Object type
pdfioObjGetType(pdfio_obj_t *obj) // I - Object
{
// TODO: Implement me
(void)obj;
pdfio_dict_t *dict; // Object dictionary
return (NULL);
if ((dict = pdfioObjGetDict(obj)) == NULL)
return (NULL);
else
return (pdfioDictGetName(dict, "Type"));
}
//
// 'pdfioObjOpenStream()' - Open an object's (data) stream for reading.
//
pdfio_stream_t * // O - Stream or `NULL` on error
pdfioObjOpenStream(pdfio_obj_t *obj) // I - Object
{
// TODO: Implement me
(void)obj;
return (NULL);
}
//
// '()' - Load an object dictionary/value.
// '_pdfioObjLoad()' - Load an object dictionary/value.
//
bool // O - `true` on success, `false` otherwise
@ -135,6 +130,8 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
*ptr; // Pointer into line
PDFIO_DEBUG("_pdfioObjLoad(obj=%p(%lu)), offset=%lu\n", obj, (unsigned long)obj->number, (unsigned long)obj->offset);
// Seek to the start of the object and read its header...
if (_pdfioFileSeek(obj->pdf, obj->offset, SEEK_SET) != obj->offset)
{
@ -170,6 +167,8 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
}
// Then grab the object value...
_pdfioFileClearTokens(obj->pdf);
if (!_pdfioValueRead(obj->pdf, &obj->value))
{
_pdfioFileError(obj->pdf, "Unable to read value for object %lu.", (unsigned long)obj->number);
@ -191,3 +190,17 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
return (true);
}
//
// 'pdfioObjOpenStream()' - Open an object's (data) stream for reading.
//
pdfio_stream_t * // O - Stream or `NULL` on error
pdfioObjOpenStream(pdfio_obj_t *obj) // I - Object
{
// TODO: Implement me
(void)obj;
return (NULL);
}