Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created January 27, 2013 07:53
Show Gist options
  • Select an option

  • Save jclulow/4647281 to your computer and use it in GitHub Desktop.

Select an option

Save jclulow/4647281 to your computer and use it in GitHub Desktop.
diff --git a/heatmap.c b/heatmap.c
index 0423050..9afd2bd 100644
--- a/heatmap.c
+++ b/heatmap.c
@@ -78,13 +78,12 @@ print_time_markers(void)
int offs;
int mark = 0;
char *marker = NULL;
+ char marker[100];
for (offs = w - LEGEND_WIDTH; offs >= 1; offs -= 10) {
int toffs = offs;
- if (marker != NULL)
- free(marker);
- (void) asprintf(&marker, "%ds|", mark);
+ (void) snprintf(&marker, 100, "%ds|", mark);
toffs -= strlen(marker);
if (toffs < 1)
@@ -95,9 +94,6 @@ print_time_markers(void)
mark += 10;
}
-
- if (marker != NULL)
- free(marker);
}
void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment