gfx/angle/src/compiler/MMap.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 #ifndef _MMAP_INCLUDED_
michael@0 8 #define _MMAP_INCLUDED_
michael@0 9
michael@0 10 //
michael@0 11 // Encapsulate memory mapped files
michael@0 12 //
michael@0 13
michael@0 14 class TMMap {
michael@0 15 public:
michael@0 16 TMMap(const char* fileName) :
michael@0 17 fSize(-1), // -1 is the error value returned by GetFileSize()
michael@0 18 fp(NULL),
michael@0 19 fBuff(0) // 0 is the error value returned by MapViewOfFile()
michael@0 20 {
michael@0 21 if ((fp = fopen(fileName, "r")) == NULL)
michael@0 22 return;
michael@0 23 char c = getc(fp);
michael@0 24 fSize = 0;
michael@0 25 while (c != EOF) {
michael@0 26 fSize++;
michael@0 27 c = getc(fp);
michael@0 28 }
michael@0 29 if (c == EOF)
michael@0 30 fSize++;
michael@0 31 rewind(fp);
michael@0 32 fBuff = (char*)malloc(sizeof(char) * fSize);
michael@0 33 int count = 0;
michael@0 34 c = getc(fp);
michael@0 35 while (c != EOF) {
michael@0 36 fBuff[count++] = c;
michael@0 37 c = getc(fp);
michael@0 38 }
michael@0 39 fBuff[count++] = c;
michael@0 40 }
michael@0 41
michael@0 42 char* getData() { return fBuff; }
michael@0 43 int getSize() { return fSize; }
michael@0 44
michael@0 45 ~TMMap() {
michael@0 46 if (fp != NULL)
michael@0 47 fclose(fp);
michael@0 48 }
michael@0 49
michael@0 50 private:
michael@0 51 int fSize; // size of file to map in
michael@0 52 FILE *fp;
michael@0 53 char* fBuff; // the actual data;
michael@0 54 };
michael@0 55
michael@0 56 #endif // _MMAP_INCLUDED_

mercurial