| File src/hstr_favorites.c changed (mode: 100644) (index dc423af..1dbfd81) |
| 7 |
7 |
============================================================================ |
============================================================================ |
| 8 |
8 |
*/ |
*/ |
| 9 |
9 |
|
|
|
10 |
|
#include <string.h> |
| 10 |
11 |
#include "include/hstr_favorites.h" |
#include "include/hstr_favorites.h" |
| 11 |
12 |
|
|
| 12 |
13 |
#define FAVORITE_SEGMENT_SIZE 10 |
#define FAVORITE_SEGMENT_SIZE 10 |
| 13 |
14 |
|
|
| 14 |
|
void favorites_init(FavoriteItems *favorites) { |
|
|
15 |
|
void favorites_init(FavoriteItems *favorites) |
|
16 |
|
{ |
| 15 |
17 |
favorites->items=NULL; |
favorites->items=NULL; |
| 16 |
18 |
favorites->count=0; |
favorites->count=0; |
| 17 |
19 |
} |
} |
| 18 |
20 |
|
|
| 19 |
|
void favorites_load(FavoriteItems *favorites) { |
|
|
21 |
|
void favorites_load(FavoriteItems *favorites) |
|
22 |
|
{ |
| 20 |
23 |
// TODO fake initialization instead of .hhrc load |
// TODO fake initialization instead of .hhrc load |
| 21 |
|
favorites->count=3; |
|
|
24 |
|
favorites->count=2; |
| 22 |
25 |
favorites->items=malloc(sizeof(char *)*favorites->count); |
favorites->items=malloc(sizeof(char *)*favorites->count); |
| 23 |
|
favorites->items[0]="a"; |
|
| 24 |
|
favorites->items[1]="b"; |
|
| 25 |
|
favorites->items[2]="c"; |
|
|
26 |
|
favorites->items[0]=malloc(2); |
|
27 |
|
strcpy(favorites->items[0],"a"); |
|
28 |
|
favorites->items[1]=malloc(2); |
|
29 |
|
strcpy(favorites->items[1],"b"); |
| 26 |
30 |
} |
} |
| 27 |
31 |
|
|
| 28 |
|
void favorites_add(FavoriteItems *favorites, char *newFavorite) { |
|
|
32 |
|
void favorites_add(FavoriteItems *favorites, char *newFavorite) |
|
33 |
|
{ |
| 29 |
34 |
favorites->items=realloc(favorites->items, sizeof(char *)*favorites->count); |
favorites->items=realloc(favorites->items, sizeof(char *)*favorites->count); |
| 30 |
35 |
favorites->items[favorites->count++]=newFavorite; |
favorites->items[favorites->count++]=newFavorite; |
|
36 |
|
|
|
37 |
|
favorites_save(favorites); |
| 31 |
38 |
} |
} |
| 32 |
39 |
|
|
| 33 |
|
void favorites_save(FavoriteItems *favorites) { |
|
|
40 |
|
void favorites_save(FavoriteItems *favorites) |
|
41 |
|
{ |
| 34 |
42 |
} |
} |