X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=packihx%2Fpackihx.c;h=72ac34f22d27c11e6dde419e4534837ac76cf2d9;hb=b48a91898c8222c328ddc5bfbebb2f21b2663780;hp=08d028e162da3388ff0ded0e770d2bc5732d8f19;hpb=b1002dc6031ca9c446997fd4aa5695617bd82fef;p=fw%2Fsdcc diff --git a/packihx/packihx.c b/packihx/packihx.c index 08d028e1..72ac34f2 100644 --- a/packihx/packihx.c +++ b/packihx/packihx.c @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------- * packihx.c: * - * utility to pack an Inter HEX format file by removing redundant + * utility to pack an Intel HEX format file by removing redundant * extended offset records and accumulating data records up to * OUTPUT_CHUNK (currently 16) bytes. * @@ -14,7 +14,15 @@ #include #include +#if defined(_MSC_VER) + +typedef unsigned char Uint8 ; +typedef unsigned Uint16 ; + +#else + #include "config.h" +#endif /* A cooked line of input. */ typedef struct _Line @@ -144,8 +152,10 @@ Line *readLine(FILE *inFile) return NULL; } bp += 2; /* Two digits consumed. */ - - line->data = (Uint8 *)malloc(line->len); + + /* Hack - always allocate something, even if len is zero. + * Avoids special case for len == 0. */ + line->data = (Uint8 *)malloc(line->len ? line->len : 1); if (!line->data) { free(line);