gd_io_dp.c (libgd-2.3.2) | : | gd_io_dp.c (libgd-2.3.3) | ||
---|---|---|---|---|
skipping to change at line 55 | skipping to change at line 55 | |||
} | } | |||
dpIOCtx; | dpIOCtx; | |||
typedef struct dpIOCtx *dpIOCtxPtr; | typedef struct dpIOCtx *dpIOCtxPtr; | |||
/* these functions operate on in-memory dynamic pointers */ | /* these functions operate on in-memory dynamic pointers */ | |||
static int allocDynamic(dynamicPtr *dp, int initialSize, void *data); | static int allocDynamic(dynamicPtr *dp, int initialSize, void *data); | |||
static int appendDynamic(dynamicPtr *dp, const void *src, int size); | static int appendDynamic(dynamicPtr *dp, const void *src, int size); | |||
static int gdReallocDynamic(dynamicPtr *dp, int required); | static int gdReallocDynamic(dynamicPtr *dp, int required); | |||
static int trimDynamic(dynamicPtr *dp); | static int trimDynamic(dynamicPtr *dp); | |||
static void gdFreeDynamicCtx(struct gdIOCtx *ctx); | static void gdFreeDynamicCtx(gdIOCtxPtr ctx); | |||
static dynamicPtr *newDynamic(int initialSize, void *data, int freeOKFlag); | static dynamicPtr *newDynamic(int initialSize, void *data, int freeOKFlag); | |||
static int dynamicPutbuf(struct gdIOCtx *, const void *, int); | static int dynamicPutbuf(gdIOCtxPtr, const void *, int); | |||
static void dynamicPutchar(struct gdIOCtx *, int a); | static void dynamicPutchar(gdIOCtxPtr, int a); | |||
static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len); | static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len); | |||
static int dynamicGetchar(gdIOCtxPtr ctx); | static int dynamicGetchar(gdIOCtxPtr ctx); | |||
static int dynamicSeek(struct gdIOCtx *, const int); | static int dynamicSeek(gdIOCtxPtr, const int); | |||
static long dynamicTell(struct gdIOCtx *); | static long dynamicTell(gdIOCtxPtr); | |||
/* | /* | |||
Function: gdNewDynamicCtx | Function: gdNewDynamicCtx | |||
Return data as a dynamic pointer. | Return data as a dynamic pointer. | |||
*/ | */ | |||
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx(int initialSize, void *data) | BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx(int initialSize, void *data) | |||
{ | { | |||
/* 2.0.23: Phil Moore: 'return' keyword was missing! */ | /* 2.0.23: Phil Moore: 'return' keyword was missing! */ | |||
return gdNewDynamicCtxEx(initialSize, data, 1); | return gdNewDynamicCtxEx(initialSize, data, 1); | |||
skipping to change at line 116 | skipping to change at line 116 | |||
ctx->ctx.tell = dynamicTell; | ctx->ctx.tell = dynamicTell; | |||
ctx->ctx.gd_free = gdFreeDynamicCtx; | ctx->ctx.gd_free = gdFreeDynamicCtx; | |||
return (gdIOCtx *)ctx; | return (gdIOCtx *)ctx; | |||
} | } | |||
/* | /* | |||
Function: gdDPExtractData | Function: gdDPExtractData | |||
*/ | */ | |||
BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size) | BGD_DECLARE(void *) gdDPExtractData(gdIOCtxPtr ctx, int *size) | |||
{ | { | |||
dynamicPtr *dp; | dynamicPtr *dp; | |||
dpIOCtx *dctx; | dpIOCtx *dctx; | |||
void *data; | void *data; | |||
dctx = (dpIOCtx *)ctx; | dctx = (dpIOCtx *)ctx; | |||
dp = dctx->dp; | dp = dctx->dp; | |||
/* clean up the data block and return it */ | /* clean up the data block and return it */ | |||
if(dp->dataGood) { | if(dp->dataGood) { | |||
skipping to change at line 146 | skipping to change at line 146 | |||
} | } | |||
} | } | |||
dp->data = NULL; | dp->data = NULL; | |||
dp->realSize = 0; | dp->realSize = 0; | |||
dp->logicalSize = 0; | dp->logicalSize = 0; | |||
return data; | return data; | |||
} | } | |||
static void gdFreeDynamicCtx(struct gdIOCtx *ctx) | static void gdFreeDynamicCtx(gdIOCtxPtr ctx) | |||
{ | { | |||
dynamicPtr *dp; | dynamicPtr *dp; | |||
dpIOCtx *dctx; | dpIOCtx *dctx; | |||
dctx = (dpIOCtx *)ctx; | dctx = (dpIOCtx *)ctx; | |||
dp = dctx->dp; | dp = dctx->dp; | |||
gdFree(ctx); | gdFree(ctx); | |||
/* clean up the data block and return it */ | /* clean up the data block and return it */ | |||
skipping to change at line 169 | skipping to change at line 169 | |||
gdFree(dp->data); | gdFree(dp->data); | |||
dp->data = NULL; | dp->data = NULL; | |||
} | } | |||
dp->realSize = 0; | dp->realSize = 0; | |||
dp->logicalSize = 0; | dp->logicalSize = 0; | |||
gdFree(dp); | gdFree(dp); | |||
} | } | |||
static long dynamicTell(struct gdIOCtx *ctx) | static long dynamicTell(gdIOCtxPtr ctx) | |||
{ | { | |||
dpIOCtx *dctx; | dpIOCtx *dctx; | |||
dctx = (dpIOCtx *)ctx; | dctx = (dpIOCtx *)ctx; | |||
return (dctx->dp->pos); | return (dctx->dp->pos); | |||
} | } | |||
static int dynamicSeek(struct gdIOCtx *ctx, const int pos) | static int dynamicSeek(gdIOCtxPtr ctx, const int pos) | |||
{ | { | |||
int bytesNeeded; | int bytesNeeded; | |||
dynamicPtr *dp; | dynamicPtr *dp; | |||
dpIOCtx *dctx; | dpIOCtx *dctx; | |||
if (pos < 0) { | if (pos < 0) { | |||
return FALSE; | return FALSE; | |||
} | } | |||
dctx = (dpIOCtx *)ctx; | dctx = (dpIOCtx *)ctx; | |||
dp = dctx->dp; | dp = dctx->dp; | |||
skipping to change at line 244 | skipping to change at line 244 | |||
gdFree(dp); | gdFree(dp); | |||
return NULL; | return NULL; | |||
} | } | |||
dp->pos = 0; | dp->pos = 0; | |||
dp->freeOK = freeOKFlag; | dp->freeOK = freeOKFlag; | |||
return dp; | return dp; | |||
} | } | |||
static int dynamicPutbuf(struct gdIOCtx *ctx, const void *buf, int size) | static int dynamicPutbuf(gdIOCtxPtr ctx, const void *buf, int size) | |||
{ | { | |||
dpIOCtx *dctx; | dpIOCtx *dctx; | |||
dctx = (dpIOCtx *)ctx; | dctx = (dpIOCtx *)ctx; | |||
appendDynamic(dctx->dp, buf, size); | appendDynamic(dctx->dp, buf, size); | |||
if(dctx->dp->dataGood) { | if(dctx->dp->dataGood) { | |||
return size; | return size; | |||
} else { | } else { | |||
return -1; | return -1; | |||
}; | }; | |||
} | } | |||
static void dynamicPutchar(struct gdIOCtx *ctx, int a) | static void dynamicPutchar(gdIOCtxPtr ctx, int a) | |||
{ | { | |||
unsigned char b; | unsigned char b; | |||
dpIOCtxPtr dctx; | dpIOCtxPtr dctx; | |||
b = a; | b = a; | |||
dctx = (dpIOCtxPtr) ctx; | dctx = (dpIOCtxPtr) ctx; | |||
appendDynamic(dctx->dp, &b, 1); | appendDynamic(dctx->dp, &b, 1); | |||
} | } | |||
End of changes. 9 change blocks. | ||||
11 lines changed or deleted | 11 lines changed or added |