Skip to content

Instantly share code, notes, and snippets.

From fe302fd2dbf41058eb745541d7c971716075b13b Mon Sep 17 00:00:00 2001
From: Benjamin Poulain <benjamin@webkit.org>
Date: Thu, 1 Sep 2011 18:52:03 +0200
Subject: [PATCH] Add parsing for the FormatVersion and the Creator lines.
The first two lines of a callgrind files are the optional lines for
the FormatVersion and Creator.
---
Callgrind Viewer/FileLoader.h | 6 ++++
Callgrind Viewer/FileLoader.m | 62 +++++++++++++++++++++++++++++++++++++++-
diff --git a/Callgrind Viewer/FileLoader.m b/Callgrind Viewer/FileLoader.m
index 823e128..2a6c906 100644
--- a/Callgrind Viewer/FileLoader.m
+++ b/Callgrind Viewer/FileLoader.m
@@ -48,6 +48,7 @@ static inline ssize_t indexOfNextNewLineChar(const char* data, size_t offset, si
if ([_pendingDataBuffer length] > 0) {
ssize_t nextNewLine = indexOfNextNewLineChar(data, 0, size);
if (nextNewLine >= 0) {
+ assert(nextNewLine <= size);
[_pendingDataBuffer appendBytes:data length:nextNewLine];