Bug 1248534 (part 5) - Remove XPTDatapool. r=khuey.

It can just be inlined into XPTState, which simplifies things.
This commit is contained in:
Nicholas Nethercote 2016-02-23 05:33:35 +11:00
parent 2324b7b000
commit 4a3a7d6c8f
3 changed files with 7 additions and 19 deletions

View File

@ -106,7 +106,7 @@ XPT_DoHeader(XPTArena *arena, XPTCursor *cursor, XPTHeader **headerp)
* as our buffer unless it is zero (not set)
*/
if (header->file_length != 0 &&
cursor->state->pool->allocated < header->file_length) {
cursor->state->pool_allocated < header->file_length) {
fputs("libxpt: File length in header does not match actual length. File may be corrupt\n",
stderr);
goto error;

View File

@ -21,7 +21,7 @@
/* can be used as lvalue */
#define CURS_POINT(cursor) \
((cursor)->state->pool->data[CURS_POOL_OFFSET(cursor)])
((cursor)->state->pool_data[CURS_POOL_OFFSET(cursor)])
static PRBool
CHECK_COUNT(XPTCursor* cursor, uint32_t space)
@ -29,7 +29,7 @@ CHECK_COUNT(XPTCursor* cursor, uint32_t space)
// Fail if we're in the data area and about to exceed the allocation.
// XXX Also fail if we're in the data area and !state->data_offset
if (cursor->pool == XPT_DATA &&
(CURS_POOL_OFFSET(cursor) + space > (cursor)->state->pool->allocated)) {
(CURS_POOL_OFFSET(cursor) + space > (cursor)->state->pool_allocated)) {
XPT_ASSERT(0);
fprintf(stderr, "FATAL: no room for %d in cursor\n", space);
return PR_FALSE;
@ -53,18 +53,12 @@ XPT_NewXDRState(char *data, uint32_t len)
goto err_free_arena;
state->arena = arena;
state->pool = XPT_NEW(arena, XPTDatapool);
state->next_cursor[0] = state->next_cursor[1] = 1;
if (!state->pool)
goto err_free_state;
state->pool->data = data;
state->pool->allocated = len;
state->pool_data = data;
state->pool_allocated = len;
return state;
err_free_state:
XPT_DELETE(arena, state);
err_free_arena:
if (arena)
XPT_DestroyArena(arena);
@ -76,7 +70,6 @@ XPT_DestroyXDRState(XPTState *state)
{
XPTArena *arena = state->arena;
XPT_DELETE(arena, state->pool);
XPT_DELETE(arena, state);
if (arena)
XPT_DestroyArena(arena);

View File

@ -17,7 +17,6 @@ extern "C" {
#endif
typedef struct XPTState XPTState;
typedef struct XPTDatapool XPTDatapool;
typedef struct XPTCursor XPTCursor;
extern XPT_PUBLIC_API(PRBool)
@ -51,13 +50,9 @@ typedef enum {
struct XPTState {
uint32_t data_offset;
uint32_t next_cursor[2];
XPTDatapool *pool;
XPTArena *arena;
};
struct XPTDatapool {
char *data;
uint32_t allocated;
char *pool_data;
uint32_t pool_allocated;
};
struct XPTCursor {