blob: 67acf545f67d5f4ccbfde31f1a09dabb5fa10394 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <stdlib.h>
#include "gd.h"
#include "gdhelpers.h"
#include "gdtest.h"
static gdImagePtr im;
#define TERMINATE(ctx, status) do { \
free(ctx); \
gdImageDestroy(im); \
exit(status); \
} while (0)
static void
failPutC(gdIOCtxPtr ctx, int c)
{
(void)c;
TERMINATE(ctx, 1);
}
static int
failPutBuf(gdIOCtxPtr ctx, const void * data, int size)
{
(void)data;
(void)size;
TERMINATE(ctx, 1);
return -1;
}
int main()
{
gdIOCtxPtr ctx;
gdSetErrorMethod(gdSilence);
im = gdImageCreate(100, 100);
ctx = (gdIOCtxPtr)malloc(sizeof(gdIOCtx));
ctx->putC = failPutC;
ctx->putBuf = failPutBuf;
gdImagePngCtx(im, ctx);
TERMINATE(ctx, 0);
return 0;
}
|