# HG changeset patch # User Paper # Date 1714790428 14400 # Node ID 2d7c810a1ac29eab6c8014e5195295d5854155da # Parent 41b74137e2015671499ee8981e69763ca3a90bb6 *: misc. cleanup diff -r 41b74137e201 -r 2d7c810a1ac2 .hgignore diff -r 41b74137e201 -r 2d7c810a1ac2 LICENSE diff -r 41b74137e201 -r 2d7c810a1ac2 src/datatypes.c --- a/src/datatypes.c Wed Apr 03 20:48:51 2024 -0400 +++ b/src/datatypes.c Fri May 03 22:40:28 2024 -0400 @@ -21,31 +21,29 @@ } size_t EDL_internal_parse_int(const char* input, size_t offset, size_t length, int* int_return) { + char* ptr_return = input; + if (offset > length) return 0; - { - char* ptr_return; - *int_return = strtol(&input[offset], &ptr_return, 10); + *int_return = strtol(&input[offset], &ptr_return, 10); - if (!ptr_return) - return 0; - } + if (ptr_return == input) + return 0; return EDL_internal_append_offset(input, offset, length); } size_t EDL_internal_parse_double(const char* input, size_t offset, size_t length, double* double_return) { + char* ptr_return = input; + if (offset > length) return 0; - { - char* ptr_return; - *double_return = strtod(&input[offset], &ptr_return); + *double_return = strtod(&input[offset], &ptr_return); - if (!ptr_return) - return 0; - } + if (ptr_return == input) + return 0; return EDL_internal_append_offset(input, offset, length); } @@ -79,7 +77,7 @@ size_t EDL_internal_parse_string(const char* input, size_t offset, size_t length, char** string_return) { size_t start, s_length; - /* will most definitely break on good filesystems */ + /* will definitely break on any good filesystem */ if (offset > length) return 0; diff -r 41b74137e201 -r 2d7c810a1ac2 src/edl.c --- a/src/edl.c Wed Apr 03 20:48:51 2024 -0400 +++ b/src/edl.c Fri May 03 22:40:28 2024 -0400 @@ -397,32 +397,31 @@ "\"Looped\";\"OnRuler\";\"MediaType\";\"FileName\";\"Stream\";\"StreamStart\";\"StreamLength\";" "\"FadeTimeIn\";\"FadeTimeOut\";\"SustainGain\";\"CurveIn\";\"GainIn\";\"CurveOut\";\"GainOut\";" "\"Layer\";\"Color\";\"CurveInR\";\"CurveOutR\":\"PlayPitch\";\"LockPitch\";\"FirstChannel\";\"Channels\"\n"; + EDL_header header = {0}; + size_t i; EDL_internal_string ret; EDL_internal_string_init(&ret); EDL_internal_string_append(&ret, order_str, strlen(order_str)); - { - EDL_header header = {0}; - if (EDL_internal_parse_header(&header, order_str, 0, strlen(order_str)) < 0) - return NULL; /* how? */ + if (EDL_internal_parse_header(&header, order_str, 0, strlen(order_str)) < 0) + return NULL; /* how? */ - size_t i; - for (i = 0; i < edl->size; i++) - EDL_dump_line(&ret, &edl->arr[i], &header); + for (i = 0; i < edl->size; i++) + EDL_dump_line(&ret, &edl->arr[i], &header); - EDL_internal_free_header(&header); - } + EDL_internal_free_header(&header); return ret.data; } void EDL_free(EDL* edl) { size_t i; - for (i = 0; i < edl->size; i++) { + + for (i = 0; i < edl->size; i++) if (edl->arr[i].filename) free(edl->arr[i].filename); - } + free(edl->arr); } diff -r 41b74137e201 -r 2d7c810a1ac2 src/str.c --- a/src/str.c Wed Apr 03 20:48:51 2024 -0400 +++ b/src/str.c Fri May 03 22:40:28 2024 -0400 @@ -4,8 +4,7 @@ #include /* rudimentary string functions so the code in edl.c isn't - * as painful to read -*/ + * as painful to read */ int EDL_internal_string_init(EDL_internal_string* str) { if (!str) diff -r 41b74137e201 -r 2d7c810a1ac2 src/util.c --- a/src/util.c Wed Apr 03 20:48:51 2024 -0400 +++ b/src/util.c Fri May 03 22:40:28 2024 -0400 @@ -8,10 +8,9 @@ size_t EDL_internal_strnlen(const char* s, size_t maxlen) { size_t len; - for (len = 0; len < maxlen; len++, s++) { + for (len = 0; len < maxlen; len++, s++) if (!*s) break; - } return len; }