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.

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

mercurial