|
43 | 43 |
|
44 | 44 | extern char **environ; |
45 | 45 |
|
46 | | - |
47 | | -static char *deptree_cache_path = NULL; |
48 | | -static char *deptree_skewed_path = NULL; |
49 | | -static char *krunlevel_path = NULL; |
50 | | -static char *starting_path = NULL; |
51 | | -static char *stopping_path = NULL; |
52 | | - |
53 | | -static char *svcdir_starting = NULL; |
54 | | -static char *svcdir_inactive = NULL; |
55 | | -static char *svcdir_started = NULL; |
56 | | -static char *svcdir_coldplugged = NULL; |
57 | | - |
58 | 46 | char * |
59 | 47 | rc_deptree_cache_path_get() { |
60 | | - if (!deptree_cache_path) { |
61 | | - deptree_cache_path = xmalloc(sizeof(char) * PATH_MAX); |
62 | | - snprintf(deptree_cache_path, PATH_MAX, "%s/%s", |
| 48 | + static char path[PATH_MAX] = { 0 }; |
| 49 | + if (!*path) { |
| 50 | + snprintf(path, PATH_MAX, "%s/%s", |
63 | 51 | rc_svcdir_get(), RC_DEPTREE_CACHE); |
64 | 52 | } |
65 | | - return deptree_cache_path; |
| 53 | + return path; |
66 | 54 | } |
67 | 55 |
|
68 | 56 | char * |
69 | 57 | rc_deptree_skewed_path_get() { |
70 | | - if (!deptree_skewed_path) { |
71 | | - deptree_skewed_path = xmalloc(sizeof(char) * PATH_MAX); |
72 | | - snprintf(deptree_skewed_path, PATH_MAX, "%s/%s", |
| 58 | + static char path[PATH_MAX] = { 0 }; |
| 59 | + if (!*path) { |
| 60 | + snprintf(path, PATH_MAX, "%s/%s", |
73 | 61 | rc_svcdir_get(), RC_DEPTREE_SKEWED); |
74 | 62 | } |
75 | | - return deptree_skewed_path; |
| 63 | + return path; |
76 | 64 | } |
77 | 65 |
|
78 | 66 | char * |
79 | 67 | rc_krunlevel_path_get() { |
80 | | - if (!krunlevel_path) { |
81 | | - krunlevel_path = xmalloc(sizeof(char) * PATH_MAX); |
82 | | - snprintf(krunlevel_path, PATH_MAX, "%s/%s", |
| 68 | + static char path[PATH_MAX] = { 0 }; |
| 69 | + if (!*path) { |
| 70 | + snprintf(path, PATH_MAX, "%s/%s", |
83 | 71 | rc_svcdir_get(), RC_KRUNLEVEL); |
84 | 72 | } |
85 | | - return krunlevel_path; |
| 73 | + return path; |
86 | 74 | } |
87 | 75 | char * |
88 | 76 | rc_starting_path_get() { |
89 | | - if (!starting_path) { |
90 | | - starting_path = xmalloc(sizeof(char) * PATH_MAX); |
91 | | - snprintf(starting_path, PATH_MAX, "%s/%s", |
| 77 | + static char path[PATH_MAX] = { 0 }; |
| 78 | + if (!*path) { |
| 79 | + snprintf(path, PATH_MAX, "%s/%s", |
92 | 80 | rc_svcdir_get(), RC_STARTING); |
93 | 81 | } |
94 | | - return starting_path; |
| 82 | + return path; |
95 | 83 | } |
96 | 84 | char * |
97 | 85 | rc_stopping_path_get() { |
98 | | - if (!stopping_path) { |
99 | | - stopping_path = xmalloc(sizeof(char) * PATH_MAX); |
100 | | - snprintf(stopping_path, PATH_MAX, "%s/%s", |
| 86 | + static char path[PATH_MAX] = { 0 }; |
| 87 | + if (!*path) { |
| 88 | + snprintf(path, PATH_MAX, "%s/%s", |
101 | 89 | rc_svcdir_get(), RC_STOPPING); |
102 | 90 | } |
103 | | - return stopping_path; |
| 91 | + return path; |
104 | 92 | } |
105 | 93 |
|
106 | 94 | char * |
107 | 95 | rc_svcdir_starting_get() { |
108 | | - if (!svcdir_starting) { |
109 | | - svcdir_starting = xmalloc(sizeof(char) * PATH_MAX); |
110 | | - snprintf(svcdir_starting, PATH_MAX, "%s/%s", |
| 96 | + static char path[PATH_MAX] = { 0 }; |
| 97 | + if (!*path) { |
| 98 | + snprintf(path, PATH_MAX, "%s/%s", |
111 | 99 | rc_svcdir_get(), RC_SVCDIR_STARTING); |
112 | 100 | } |
113 | | - return svcdir_starting; |
| 101 | + return path; |
114 | 102 | } |
115 | 103 |
|
116 | 104 | char * |
117 | 105 | rc_svcdir_inactive_get() { |
118 | | - if (!svcdir_inactive) { |
119 | | - svcdir_inactive = xmalloc(sizeof(char) * PATH_MAX); |
120 | | - snprintf(svcdir_inactive, PATH_MAX, "%s/%s", |
| 106 | + static char path[PATH_MAX] = { 0 }; |
| 107 | + if (!*path) { |
| 108 | + snprintf(path, PATH_MAX, "%s/%s", |
121 | 109 | rc_svcdir_get(), RC_SVCDIR_INACTIVE); |
122 | 110 | } |
123 | | - return svcdir_inactive; |
| 111 | + return path; |
124 | 112 | } |
125 | 113 |
|
126 | 114 | char * |
127 | 115 | rc_svcdir_started_get() { |
128 | | - if (!svcdir_started) { |
129 | | - svcdir_started = xmalloc(sizeof(char) * PATH_MAX); |
130 | | - snprintf(svcdir_started, PATH_MAX, "%s/%s", |
| 116 | + static char path[PATH_MAX] = { 0 }; |
| 117 | + if (!*path) { |
| 118 | + snprintf(path, PATH_MAX, "%s/%s", |
131 | 119 | rc_svcdir_get(), RC_SVCDIR_STARTED); |
132 | 120 | } |
133 | | - return svcdir_started; |
| 121 | + return path; |
134 | 122 | } |
135 | 123 |
|
136 | 124 | char * |
137 | 125 | rc_svcdir_coldplugged_get() { |
138 | | - if (!svcdir_coldplugged) { |
139 | | - svcdir_coldplugged = xmalloc(sizeof(char) * PATH_MAX); |
140 | | - snprintf(svcdir_coldplugged, PATH_MAX, "%s/%s", |
| 126 | + static char path[PATH_MAX] = { 0 }; |
| 127 | + if (!*path) { |
| 128 | + snprintf(path, PATH_MAX, "%s/%s", |
141 | 129 | rc_svcdir_get(), RC_SVCDIR_COLDPLUGGED); |
142 | 130 | } |
143 | | - return svcdir_coldplugged; |
| 131 | + return path; |
144 | 132 | } |
145 | 133 |
|
146 | 134 | bool |
|
0 commit comments