state->pool = PR_NEW(XPTDatapool); if (!state->pool) { PR_FREE(state); return NULL; } state->pool->count = 0; state->pool->bit = 0; if (mode == XPT_DECODE) { state->pool->data = data; state->pool->allocated = len; } else { state->pool->data = PR_MALLOC(XPT_GROW_CHUNK); if (!state->pool->data) { PR_FREE(state->pool);
for (i = 0; i < 2; i++) { state->pools[i] = PR_NEW(XPTDatapool); if (!state->pools[i]) { if (i) { PR_FREE(state->pools[0]->data); PR_FREE(state->pools[0]); }
XPT_NewXDRState(XPTMode mode, char *data, uint32 len){    XPTState *state;    state = PR_NEW(XPTState);    if (!state)        return NULL;    state->mode = mode;    state->pool = PR_NEW(XPTDatapool);    if (!state->pool) {        PR_FREE(state);        return NULL;    }    state->pool->count = 0;    state->pool->bit = 0;    if (mode == XPT_DECODE) {        state->pool->data = data;        state->pool->allocated = len;    } else {        state->pool->data = PR_MALLOC(XPT_GROW_CHUNK);        if (!state->pool->data) {            PR_FREE(state->pool);            PR_FREE(state);            return NULL;        }        state->data->allocated = XPT_GROW_CHUNK;    }}