browser/components/translation/cld2/internal/cld2_dynamic_data_loader.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright 2014 Google Inc. All Rights Reserved.
michael@0 2 //
michael@0 3 // Licensed under the Apache License, Version 2.0 (the "License");
michael@0 4 // you may not use this file except in compliance with the License.
michael@0 5 // You may obtain a copy of the License at
michael@0 6 //
michael@0 7 // http://www.apache.org/licenses/LICENSE-2.0
michael@0 8 //
michael@0 9 // Unless required by applicable law or agreed to in writing, software
michael@0 10 // distributed under the License is distributed on an "AS IS" BASIS,
michael@0 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 12 // See the License for the specific language governing permissions and
michael@0 13 // limitations under the License.
michael@0 14
michael@0 15 #ifndef CLD2_INTERNAL_CLD2_DYNAMIC_DATA_LOADER_H_
michael@0 16 #define CLD2_INTERNAL_CLD2_DYNAMIC_DATA_LOADER_H_
michael@0 17
michael@0 18 #include "scoreonescriptspan.h"
michael@0 19 #include "cld2_dynamic_data.h"
michael@0 20
michael@0 21 namespace CLD2DynamicDataLoader {
michael@0 22
michael@0 23 // Read a header from the specified file and return it.
michael@0 24 // The header returned is dynamically allocated; you must 'delete' the array
michael@0 25 // of TableHeaders as well as the returned FileHeader* when done.
michael@0 26 CLD2DynamicData::FileHeader* loadHeader(const char* fileName);
michael@0 27
michael@0 28 // Load data directly into a ScoringTables structure using a private, read-only
michael@0 29 // mmap and return the newly-allocated structure.
michael@0 30 // The out-parameter "mmapAddressOut" is a pointer to a void*; the starting
michael@0 31 // address of the mmap()'d block will be written here.
michael@0 32 // The out-parameter "mmapLengthOut" is a pointer to an int; the length of the
michael@0 33 // mmap()'d block will be written here.
michael@0 34 // It is up to the caller to delete
michael@0 35 CLD2::ScoringTables* loadDataFile(const char* fileName,
michael@0 36 void** mmapAddressOut, int* mmapLengthOut);
michael@0 37
michael@0 38 // Given pointers to the data from a previous invocation of loadDataFile,
michael@0 39 // unloads the data safely - freeing and deleting any malloc'd/new'd objects.
michael@0 40 // When this method returns, the mmap has been deleted, as have all the scoring
michael@0 41 // tables; the pointers passed in are all zeroed, such that:
michael@0 42 // *scoringTables == NULL
michael@0 43 // *mmapAddress == NULL
michael@0 44 // mmapLength == NULL
michael@0 45 // This is the only safe way to unload data that was previously loaded, as there
michael@0 46 // is an unfortunate mixture of new and malloc involved in building the
michael@0 47 // in-memory represtation of the data.
michael@0 48 void unloadData(CLD2::ScoringTables** scoringTables,
michael@0 49 void** mmapAddress, int* mmapLength);
michael@0 50
michael@0 51 } // End namespace CLD2DynamicDataExtractor
michael@0 52 #endif // CLD2_INTERNAL_CLD2_DYNAMIC_DATA_EXTRACTOR_H_

mercurial