-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdata.cpp
More file actions
54 lines (46 loc) · 1.24 KB
/
data.cpp
File metadata and controls
54 lines (46 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//========================================================================
// Data
//========================================================================
// @brief: loading data function
#include "data.h"
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
// get 80 labels(classes) and store them into 2D array
char **get_labels(char *filename)
{
// get label list
list *plist = get_paths(filename);
/*
// verify plist
node * pnode = plist->front;
int counter = 0;
printf("name_list size: %d;\n",plist->size);
while(pnode->next)
{
pnode = pnode->next;
printf("name_list NO. %d: %s; \n",counter, (char *)pnode->val);
counter++;
}
*/
char **labels = (char **)list_to_array(plist); //???
free_list(plist);
return labels;
}
// read each line from a file, return a list
list *get_paths(char *filename)
{
char *line;
FILE *file = fopen(filename, "r");
if(!file)
{
file_error(filename);
}
// make a new list
list *lines = make_list();
// store every line (classes) into the list
while((line=fgetl(file)))
{
list_insert(lines, line);
}
fclose(file);
return lines;
}