Overview
| Comment: | OFEmbeddedIRIHandler: Always initialize mutex |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
06c5bad0bde50148b8c64f0ae813a4d9 |
| User & Date: | js on 2023-03-26 13:18:55 |
| Other Links: | manifest | tags |
Context
|
2023-03-26
| ||
| 13:25 | tests/ImportTest:.m: Test @import instead (check-in: f439c0437e user: js tags: trunk) | |
| 13:18 | OFEmbeddedIRIHandler: Always initialize mutex (check-in: 06c5bad0bd user: js tags: trunk) | |
| 13:11 | Don't install OFEmbeddedIRIHandler.h (check-in: e78254fca5 user: js tags: trunk) | |
Changes
Modified src/OFEmbeddedIRIHandler.m from [ec56eba1c1] to [5dec058e36].
| ︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 | OFString *path; const uint8_t *bytes; size_t size; } *embeddedFiles = NULL; size_t numEmbeddedFiles = 0; #ifdef OF_HAVE_THREADS static OFPlainMutex mutex; static void | > | < | > > > > > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
OFString *path;
const uint8_t *bytes;
size_t size;
} *embeddedFiles = NULL;
size_t numEmbeddedFiles = 0;
#ifdef OF_HAVE_THREADS
static OFPlainMutex mutex;
static OFOnceControl mutexOnceControl = OFOnceControlInitValue;
static void
initMutex(void)
{
OFEnsure(OFPlainMutexNew(&mutex) == 0);
}
#endif
void
OFRegisterEmbeddedFile(OFString *path, const uint8_t *bytes, size_t size)
{
#ifdef OF_HAVE_THREADS
OFOnce(&mutexOnceControl, initMutex);
OFEnsure(OFPlainMutexLock(&mutex) == 0);
#endif
embeddedFiles = realloc(embeddedFiles,
sizeof(*embeddedFiles) * (numEmbeddedFiles + 1));
OFEnsure(embeddedFiles != NULL);
embeddedFiles[numEmbeddedFiles].path = path;
embeddedFiles[numEmbeddedFiles].bytes = bytes;
embeddedFiles[numEmbeddedFiles].size = size;
numEmbeddedFiles++;
#ifdef OF_HAVE_THREADS
OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
#endif
}
@implementation OFEmbeddedIRIHandler
+ (void)initialize
{
if (self == [OFEmbeddedIRIHandler class])
OFOnce(&mutexOnceControl, initMutex);
}
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
OFString *path;
if (![IRI.scheme isEqual: @"embedded"] || IRI.host.length > 0 ||
IRI.port != nil || IRI.user != nil || IRI.password != nil ||
IRI.query != nil || IRI.fragment != nil)
|
| ︙ | ︙ |