Fixes small extra free that wasn't being detected for some reason
This commit is contained in:
parent
4b49d6f510
commit
b154e897c5
@ -11,6 +11,7 @@ $(TARGET): $(OBJ)
|
|||||||
|
|
||||||
debug:
|
debug:
|
||||||
gcc -g $(FILES)
|
gcc -g $(FILES)
|
||||||
|
mv a.out ../build/
|
||||||
|
|
||||||
main.o: include/hex.h include/file.h
|
main.o: include/hex.h include/file.h
|
||||||
hex.o: include/hex.h
|
hex.o: include/hex.h
|
||||||
|
@ -85,7 +85,7 @@ static void write_offset(int num, FILE* stream)
|
|||||||
fprintf(stream, "%08d", num);
|
fprintf(stream, "%08d", num);
|
||||||
else
|
else
|
||||||
fprintf(stream, "%08x", num);
|
fprintf(stream, "%08x", num);
|
||||||
fprintf(stream, ": %s", GREEN_TEXT_STR);
|
fprintf(stream, ": %s", (flags.coloured) ? GREEN_TEXT_STR : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_text(char** text, FILE* stream)
|
static void write_text(char** text, FILE* stream)
|
||||||
@ -123,12 +123,12 @@ static void standard_output(char** text, FILE* stream)
|
|||||||
for (i = 0; i < (flags.cols * 2); i += (flags.octets * 2)) {
|
for (i = 0; i < (flags.cols * 2); i += (flags.octets * 2)) {
|
||||||
for (j = 0; j < (flags.octets * 2); j += 2)
|
for (j = 0; j < (flags.octets * 2); j += 2)
|
||||||
write_octet(((*text) + i + j)[0], ((*text) + i + j)[1], stream);
|
write_octet(((*text) + i + j)[0], ((*text) + i + j)[1], stream);
|
||||||
|
if (!flags.postscript)
|
||||||
fprintf(stream, " ");
|
fprintf(stream, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void display_hex_chunk(hex_chunk_t* chunk, FILE* stream)
|
void display_hex_chunk(hex_chunk_t* chunk, FILE* stream)
|
||||||
{
|
{
|
||||||
if (!flags.postscript && !flags.c_style)
|
if (!flags.postscript && !flags.c_style)
|
||||||
|
@ -17,6 +17,7 @@ static struct argp_option options[] = {
|
|||||||
{"len", 'l', "len", 0, "stop after <len> octets.", 0},
|
{"len", 'l', "len", 0, "stop after <len> octets.", 0},
|
||||||
{"uppercase", 'u', 0, 0, "use upper case hex letters.", 0},
|
{"uppercase", 'u', 0, 0, "use upper case hex letters.", 0},
|
||||||
{"decimaloffset", 'd', 0, 0, "show offset in decimal instead of hex.", 0},
|
{"decimaloffset", 'd', 0, 0, "show offset in decimal instead of hex.", 0},
|
||||||
|
{"ps", 'p', 0, 0, "output in postscript plain hexdump style.", 0},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,6 +41,9 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
|||||||
case 'd':
|
case 'd':
|
||||||
flags->decimaloffset = true;
|
flags->decimaloffset = true;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
flags->postscript = true;
|
||||||
|
flags->coloured = false;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
if (state->arg_num >= 2)
|
if (state->arg_num >= 2)
|
||||||
argp_usage(state);
|
argp_usage(state);
|
||||||
@ -137,10 +141,7 @@ int main(int argc, char* argv[])
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (lines[i].line != -1)
|
while (lines[i].line != -1)
|
||||||
free_hex_chunk(&(lines[i++]));
|
free_hex_chunk(&(lines[i++]));
|
||||||
free_hex_chunk(&(lines[i]));
|
|
||||||
|
|
||||||
free(lines);
|
free(lines);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user