comparison util.c @ 2158:bdd83b47d78a

Implement config file migrations and add iso and cue to extension list
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 May 2022 09:10:54 -0700
parents 237068a25523
children a8af8d898a7c
comparison
equal deleted inserted replaced
2157:da7890445962 2158:bdd83b47d78a
51 char * ret = malloc(total + 1); 51 char * ret = malloc(total + 1);
52 *ret = 0; 52 *ret = 0;
53 for (int i = 0; i < num_parts; i++) { 53 for (int i = 0; i < num_parts; i++) {
54 strcat(ret, parts[i]); 54 strcat(ret, parts[i]);
55 } 55 }
56 return ret;
57 }
58
59 char * alloc_join(int num_parts, char const **parts, char sep)
60 {
61 int total = num_parts ? num_parts - 1 : 0;
62 for (int i = 0; i < num_parts; i++) {
63 total += strlen(parts[i]);
64 }
65 char * ret = malloc(total + 1);
66 char *cur = ret;
67 for (int i = 0; i < num_parts; i++) {
68 size_t s = strlen(parts[i]);
69 if (i) {
70 *(cur++) = sep;
71 }
72 memcpy(cur, parts[i], s);
73 cur += s;
74 }
75 *cur = 0;
56 return ret; 76 return ret;
57 } 77 }
58 78
59 typedef struct { 79 typedef struct {
60 uint32_t start; 80 uint32_t start;