annotate src/main.c @ 2:d00bc412900e

*: fix up lots of stuff and make the thing actually usable
author Paper <mrpapersonic@gmail.com>
date Sun, 24 Dec 2023 20:01:30 -0500
parents 0ea1ec2da443
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include <string.h>
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include <stdbool.h>
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include <stdio.h>
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <stdlib.h>
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <stdint.h>
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "edl.h"
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
8 #define strnchr(haystack, needle, length) memchr(haystack, needle, strnlen(haystack, length))
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
10 static uint32_t EDL_internal_crcn32b(const unsigned char* restrict message, size_t length) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
11 uint32_t crc = 0xFFFFFFFF;
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
13 size_t i;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
14 for (i = 0; i < length && message[i]; i++) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
15 crc = crc ^ message[i];
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
16 size_t j;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
17 for (j = 0; j < 8; j++)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
18 crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1));
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
20
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 return ~crc;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 /* This parses the first line of the EDL and
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
25 * creates an array with CRC32 hashes in
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
26 * the order of the strings.
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
27 */
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
28 static uint32_t* EDL_internal_parse_first_line(const char* data, size_t* restrict length) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
29 size_t hashes_size = 32, current_hash = 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
30 uint32_t* hashes = malloc(hashes_size * sizeof(uint32_t));
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
31
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
32 size_t len_until_newline = strchr(data, '\n') - data, i, b;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
33 for (i = 0, b = 0; i < len_until_newline; i++, b++) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
34 if (data[i] == ';') {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
35 if (current_hash >= hashes_size)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
36 hashes = realloc(hashes, (hashes_size *= 2) * sizeof(uint32_t));
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
37 hashes[current_hash++] = EDL_internal_crcn32b((const unsigned char*)&data[i - b], b);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
38 b = -1; // ew
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
39 }
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
41
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
42 *length = current_hash;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
43
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 return hashes;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 /* -- Functions to extract different datatypes -- */
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
49 static size_t EDL_internal_append_offset(const char* input, size_t offset, size_t length) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
50 size_t s = 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
51
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
52 s += strchr(&input[offset + s], ';') - &input[offset];
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
53 if (s + offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
54 return s;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
55
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
56 s += strspn(&input[offset + s], ";\t ");
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
57 if (s + offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
58 return s;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
59
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
60 return s;
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
63 static size_t EDL_internal_get_int(const char* input, size_t offset, size_t length, int* int_return) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
64 if (offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
65 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
66
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
67 {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
68 char* ptr_return;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
69 *int_return = strtol(&input[offset], &ptr_return, 10);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
70
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
71 if (!ptr_return)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
72 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
73 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
74
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
75 return EDL_internal_append_offset(input, offset, length);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
78 static size_t EDL_internal_get_double(const char* input, size_t offset, size_t length, double* double_return) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
79 if (offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
80 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
81
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
82 {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
83 char* ptr_return;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
84 *double_return = strtod(&input[offset], &ptr_return);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
85
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
86 if (!ptr_return)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
87 return 0;
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
89
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
90 return EDL_internal_append_offset(input, offset, length);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
93 static size_t EDL_internal_get_bool(const char* input, size_t offset, size_t length, bool* bool_return) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
94 if (offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
95 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
96
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
97 if (strncmp((input + offset), "TRUE", 4))
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
98 *bool_return = true;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
99 else if (strncmp((input + offset), "FALSE", 5))
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
100 *bool_return = false;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
101
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
102 return EDL_internal_append_offset(input, offset, length);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
103 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
104
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
105 static size_t EDL_internal_get_media_type(const char* input, size_t offset, size_t length, MediaType* media_return) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
106 if (offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
107 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
108
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
109 if (strncmp(input + offset, "VIDEO", 5))
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
110 *media_return = MEDIATYPE_VIDEO;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
111 else if (strncmp(input + offset, "AUDIO", 5))
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
112 *media_return = MEDIATYPE_AUDIO;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
113
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
114 return EDL_internal_append_offset(input, offset, length);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
117 static size_t EDL_internal_get_string(const char* input, size_t offset, size_t length, char** string_return) {
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118 /* Windows filenames will *NEVER* include double quotes.
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 This might break with EDL files created with Reaper on Linux. */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
120 if (offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
121 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
122
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
123 size_t start = strchr(&input[offset], '\"') - &input[offset] + 1;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
124 if (start + offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
125 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
126
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
127 size_t s_length = strchr(&input[offset + start], '\"') - &input[offset] - start;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
128 if (start + s_length + offset > length)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
129 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
130
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
131 *string_return = malloc((s_length + 1) * sizeof(char));
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
132 if (!*string_return)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
133 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
134
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
135 memcpy(*string_return, &input[offset + start], s_length);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
136 (*string_return)[s_length] = '\0';
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
137
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
138 return EDL_internal_append_offset(input, offset, length);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
141 /* memory management routines */
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
142
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
143 static int EDL_internal_reallocate(EDL_file* input, size_t new_capacity) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
144 input->arr = realloc(input->arr, new_capacity * sizeof(EDL_line));
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
145 if (!input->arr)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
146 return 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
147
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
148 if (new_capacity > input->capacity)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
149 memset(input->arr + input->capacity, 0, new_capacity - input->capacity);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
150
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
151 input->capacity = new_capacity;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
152
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
153 return 1;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
154 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
155
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
156 static int EDL_internal_allocate_memory(EDL_file* input) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
157 return EDL_internal_reallocate(input, input->capacity ? input->capacity * 2 : 16);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
158 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
159
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
160 static int EDL_internal_shrink_memory_to_fit(EDL_file* input) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
161 return EDL_internal_reallocate(input, input->size);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
164 /* the important function */
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
165 EDL_file EDL_parse(const char* data, size_t length) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
166 EDL_file edl = {0};
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
167 if (!EDL_internal_allocate_memory(&edl))
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
168 return edl;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
169
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
170 size_t order_size = 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
171 uint32_t* order = EDL_internal_parse_first_line(data, &order_size);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
172
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
173 size_t offset = 0;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
174 while ((offset = strnchr(data + offset + 1, '\n', length - offset) - (void*)data) < length) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
175 size_t local_offset = offset; // this is so our original offset stays intact
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
176
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
177 bool ok = true;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
178
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
179 for (int i = 0; i < order_size; i++) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
180 #define ADD_TO_OFFSET(x, a) \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
181 { \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
182 size_t o = a(data, local_offset, length, &edl.arr[edl.size].x); \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
183 if (!o) \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
184 ok = false; \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
185 local_offset += o; \
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
186 }
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187 switch (order[i]) {
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
188 case 0x1541c503: /* ID */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
189 ADD_TO_OFFSET(id, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191 case 0x4b211812: /* Track */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
192 ADD_TO_OFFSET(track, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
193 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
194 case 0xbb46516f: /* StartTime */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
195 ADD_TO_OFFSET(start_time, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
197 case 0xaeac5df7: /* Length */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
198 ADD_TO_OFFSET(length, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
199 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
200 case 0x03834606: /* PlayRate */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
201 ADD_TO_OFFSET(play_rate, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
202 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
203 case 0x0c2083d3: /* Locked */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
204 ADD_TO_OFFSET(locked, EDL_internal_get_bool);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
206 case 0xe60c8b1d: /* Normalized */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
207 ADD_TO_OFFSET(normalized, EDL_internal_get_bool);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
208 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
209 case 0xbe5802c9: /* StretchMethod */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
210 ADD_TO_OFFSET(stretch_method, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
211 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
212 case 0x4ec8be4c: /* Looped */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
213 ADD_TO_OFFSET(looped, EDL_internal_get_bool);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
214 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
215 case 0xe6cb84d1: /* OnRuler */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
216 ADD_TO_OFFSET(on_ruler, EDL_internal_get_bool);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
217 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
218 case 0x035f84c2: /* MediaType */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
219 ADD_TO_OFFSET(media_type, EDL_internal_get_media_type);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
221 case 0x379d32c5: /* FileName */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
222 ADD_TO_OFFSET(filename, EDL_internal_get_string);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
223 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
224 case 0x9f334738: /* Stream */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
225 ADD_TO_OFFSET(stream, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
226 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
227 case 0x07b4e0e7: /* StreamStart */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
228 ADD_TO_OFFSET(stream_start, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
229 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
230 case 0x8f16c7b8: /* StreamLength */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
231 ADD_TO_OFFSET(stream_length, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
232 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
233 case 0xd2edd7e4: /* FadeTimeIn */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
234 ADD_TO_OFFSET(fade_time_in, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236 case 0x792e8c40: /* FadeTimeOut */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
237 ADD_TO_OFFSET(fade_time_out, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
238 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
239 case 0x98374657: /* SustainGain */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
240 ADD_TO_OFFSET(sustain_gain, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
241 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
242 case 0x3e998b1f: /* CurveIn */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
243 ADD_TO_OFFSET(curve_in, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
244 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 case 0x82fb09c4: /* GainIn */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
246 ADD_TO_OFFSET(gain_in, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
248 case 0x53add388: /* CurveOut */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
249 ADD_TO_OFFSET(curve_out, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
250 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
251 case 0x4210ba56: /* GainOut */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
252 ADD_TO_OFFSET(gain_out, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
253 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
254 case 0x89c4df6c: /* Layer */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
255 ADD_TO_OFFSET(layer, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
256 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
257 case 0xadf2f1a3: /* Color */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
258 ADD_TO_OFFSET(color, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
259 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
260 case 0xa56b43e1: /* CurveInR */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
261 ADD_TO_OFFSET(curve_in_r, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
262 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
263 case 0xcb6d715e: /* CurveOutR */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
264 ADD_TO_OFFSET(curve_out_r, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
265 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
266 case 0x9da1b9ed: /* PlayPitch */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
267 ADD_TO_OFFSET(play_pitch, EDL_internal_get_double);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
268 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
269 case 0x2bda6ed4: /* LockPitch */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
270 ADD_TO_OFFSET(lock_pitch, EDL_internal_get_bool);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
271 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
272 case 0x3071a4c6: /* FirstChannel */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
273 ADD_TO_OFFSET(first_channel, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
274 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
275 case 0x7de1bd40: /* Channels */
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
276 ADD_TO_OFFSET(channels, EDL_internal_get_int);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
277 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
278 default:
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
279 /* ... what */
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
280 break;
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
281 }
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
282 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
283
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
284 if (!ok)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
285 break;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
286
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
287 if (++edl.size >= edl.capacity)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
288 EDL_internal_allocate_memory(&edl);
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
289 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
290
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
291 EDL_internal_shrink_memory_to_fit(&edl);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
292
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
293 free(order);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
294
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
295 return edl;
0
0ea1ec2da443 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
296 }
2
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
297
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
298 void EDL_free(EDL_file file) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
299 size_t i;
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
300 for (i = 0; i < file.size; i++) {
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
301 if (file.arr[i].filename)
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
302 free(file.arr[i].filename);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
303 }
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
304 free(file.arr);
d00bc412900e *: fix up lots of stuff and make the thing actually usable
Paper <mrpapersonic@gmail.com>
parents: 0
diff changeset
305 }