Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// Copyright 2019 Google
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
 
15
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
16
 
17
#pragma once
18
 
19
#include <stdbool.h>
20
#include <sys/types.h>
21
 
22
typedef enum { CLS_READONLY = 0, CLS_READWRITE = 1 } FIRCLSAllocationType;
23
 
24
typedef struct {
25
  size_t size;
26
  void* start;
27
  _Atomic(void*) volatile cursor;
28
} FIRCLSAllocationRegion;
29
 
30
typedef struct {
31
  void* buffer;
32
  bool protectionEnabled;
33
  FIRCLSAllocationRegion writeableRegion;
34
  FIRCLSAllocationRegion readableRegion;
35
} FIRCLSAllocator;
36
typedef FIRCLSAllocator* FIRCLSAllocatorRef;
37
 
38
FIRCLSAllocatorRef FIRCLSAllocatorCreate(size_t writableSpace, size_t readableSpace);
39
void FIRCLSAllocatorDestroy(FIRCLSAllocatorRef allocator);
40
 
41
bool FIRCLSAllocatorProtect(FIRCLSAllocatorRef allocator);
42
bool FIRCLSAllocatorUnprotect(FIRCLSAllocatorRef allocator);
43
 
44
void* FIRCLSAllocatorSafeAllocate(FIRCLSAllocatorRef allocator,
45
                                  size_t size,
46
                                  FIRCLSAllocationType type);
47
const char* FIRCLSAllocatorSafeStrdup(FIRCLSAllocatorRef allocator, const char* string);
48
void FIRCLSAllocatorFree(FIRCLSAllocatorRef allocator, void* ptr);