libmobi
C library for handling MOBI format ebook documents
Functions
memory.c File Reference

Functions for initializing and releasing structures and data containers. More...

#include <stdlib.h>
#include "memory.h"
#include "debug.h"
#include "util.h"

Functions

MOBIDatamobi_init (void)
 Initializer for MOBIData structure. More...
 
void mobi_free_mh (MOBIMobiHeader *mh)
 Free MOBIMobiHeader structure. More...
 
void mobi_free_rec (MOBIData *m)
 Free all MOBIPdbRecord structures and its respective data attached to MOBIData structure. More...
 
void mobi_free_eh (MOBIData *m)
 Free all MOBIExthHeader structures and its respective data attached to MOBIData structure. More...
 
void mobi_free_next (MOBIData *m)
 Free MOBIData structure for currenly unused hybrid part and all its children. More...
 
void mobi_free (MOBIData *m)
 Free MOBIData structure and all its children. More...
 
MOBIHuffCdicmobi_init_huffcdic (void)
 Initialize and return MOBIHuffCdic structure. More...
 
void mobi_free_huffcdic (MOBIHuffCdic *huffcdic)
 Free MOBIHuffCdic structure and all its children. More...
 
MOBIRawmlmobi_init_rawml (const MOBIData *m)
 Initialize and return MOBIRawml structure. More...
 
void mobi_free_fdst (MOBIFdst *fdst)
 Free MOBIFdst structure and all its children. More...
 
MOBIIndxmobi_init_indx (void)
 Initialize and return MOBIIndx structure. More...
 
void mobi_free_index_entries (MOBIIndx *indx)
 Free index entries data and all its children. More...
 
void mobi_free_indx (MOBIIndx *indx)
 Free MOBIIndx structure and all its children. More...
 
void mobi_free_tagx (MOBITagx *tagx)
 Free MOBITagx structure and all its children. More...
 
void mobi_free_ordt (MOBIOrdt *ordt)
 Free MOBIOrdt structure and all its children. More...
 
void mobi_free_part (MOBIPart *part, int free_data)
 Free MOBIPart structure. More...
 
void mobi_free_opf_data (MOBIPart *part)
 Free MOBIPart structure for opf and ncx data. More...
 
void mobi_free_font_data (MOBIPart *part)
 Free MOBIPart structure for decoded font data. More...
 
void mobi_free_rawml (MOBIRawml *rawml)
 Free MOBIRawml structure allocated by mobi_init_rawml() More...
 

Detailed Description

Functions for initializing and releasing structures and data containers.

Copyright (c) 2014 Bartek Fabiszewski http://www.fabiszewski.net

This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/

Function Documentation

◆ mobi_free_eh()

void mobi_free_eh ( MOBIData m)

Free all MOBIExthHeader structures and its respective data attached to MOBIData structure.

Each MOBIExthHeader structure holds metadata and data for each EXTH record

Parameters
[in,out]mMOBIData structure

◆ mobi_free_fdst()

void mobi_free_fdst ( MOBIFdst fdst)

Free MOBIFdst structure and all its children.

Parameters
[in]fdstMOBIFdst structure

◆ mobi_free_font_data()

void mobi_free_font_data ( MOBIPart part)

Free MOBIPart structure for decoded font data.

Parameters
[in]partMOBIPart structure

◆ mobi_free_huffcdic()

void mobi_free_huffcdic ( MOBIHuffCdic huffcdic)

Free MOBIHuffCdic structure and all its children.

Parameters
[in]huffcdicMOBIData structure

◆ mobi_free_index_entries()

void mobi_free_index_entries ( MOBIIndx indx)

Free index entries data and all its children.

Parameters
[in]indxMOBIIndx structure that holds indx->entries

◆ mobi_free_indx()

void mobi_free_indx ( MOBIIndx indx)

Free MOBIIndx structure and all its children.

Parameters
[in]indxMOBIIndx structure that holds indx->entries

◆ mobi_free_mh()

void mobi_free_mh ( MOBIMobiHeader mh)

Free MOBIMobiHeader structure.

Parameters
[in]mhMOBIMobiHeader structure

◆ mobi_free_next()

void mobi_free_next ( MOBIData m)

Free MOBIData structure for currenly unused hybrid part and all its children.

Parameters
[in]mMOBIData structure

◆ mobi_free_opf_data()

void mobi_free_opf_data ( MOBIPart part)

Free MOBIPart structure for opf and ncx data.

Parameters
[in]partMOBIPart structure

◆ mobi_free_ordt()

void mobi_free_ordt ( MOBIOrdt ordt)

Free MOBIOrdt structure and all its children.

Parameters
[in]ordtMOBIOrdt structure

◆ mobi_free_part()

void mobi_free_part ( MOBIPart part,
int  free_data 
)

Free MOBIPart structure.

Pointer to data may point to memory area also used by record->data. So we need a flag to leave the memory allocated, while freeing MOBIPart structure

Parameters
[in]partMOBIPart structure
[in]free_dataFlag, if set - a pointer to part->data is also released, otherwise not released

◆ mobi_free_rec()

void mobi_free_rec ( MOBIData m)

Free all MOBIPdbRecord structures and its respective data attached to MOBIData structure.

Each MOBIPdbRecord structure holds metadata and data for each pdb record

Parameters
[in,out]mMOBIData structure

◆ mobi_free_tagx()

void mobi_free_tagx ( MOBITagx tagx)

Free MOBITagx structure and all its children.

Parameters
[in]tagxMOBITagx structure

◆ mobi_init_huffcdic()

MOBIHuffCdic* mobi_init_huffcdic ( void  )

Initialize and return MOBIHuffCdic structure.

MOBIHuffCdic structure holds parsed data from HUFF, CDIC records. It is used for huffman decompression. Initialized structure is a child of MOBIData structure. It must be freed with mobi_free_huffcdic().

Returns
MOBIHuffCdic on success, NULL otherwise

◆ mobi_init_indx()

MOBIIndx* mobi_init_indx ( void  )

Initialize and return MOBIIndx structure.

MOBIIndx structure holds INDX index record entries. Must be freed with mobi_free_indx()

Returns
MOBIIndx on success, NULL otherwise