texdepends/fs.c

41 lines
609 B
C
Raw Normal View History

2017-10-25 18:36:02 +02:00
/*
* fs.c
*
* Created on: 20.10.2017
* Author: julian
*/
#include "fs.h"
#include <stdlib.h>
#include <string.h>
void path_join(struct path *p1, struct path *p2) {
size_t other = p2->len;
while(other) {
p1->entries = realloc(p1->entries, sizeof(const char*) * (p1->len+1));
if (p1->entries == NULL) {
// OUT OF MEM, oper incomplete
return;
}
p1->entries[p1->len] = strdup(p2->entries[p2->len - other]);
other--;
p1->len++;
}
}
void free_path(struct path * p) {
while(p->len) {
free(p->entries[p->len-1]);
p->len--;
}
// free the old array
free(p->entries);
}