/src/libcreg/libfcache/libfcache_cache_value.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Cache value functions  | 
3  |  |  *  | 
4  |  |  * Copyright (C) 2010-2024, Joachim Metz <joachim.metz@gmail.com>  | 
5  |  |  *  | 
6  |  |  * Refer to AUTHORS for acknowledgements.  | 
7  |  |  *  | 
8  |  |  * This program is free software: you can redistribute it and/or modify  | 
9  |  |  * it under the terms of the GNU Lesser General Public License as published by  | 
10  |  |  * the Free Software Foundation, either version 3 of the License, or  | 
11  |  |  * (at your option) any later version.  | 
12  |  |  *  | 
13  |  |  * This program is distributed in the hope that it will be useful,  | 
14  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
15  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  | 
16  |  |  * GNU General Public License for more details.  | 
17  |  |  *  | 
18  |  |  * You should have received a copy of the GNU Lesser General Public License  | 
19  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>.  | 
20  |  |  */  | 
21  |  |  | 
22  |  | #include <common.h>  | 
23  |  | #include <memory.h>  | 
24  |  | #include <types.h>  | 
25  |  |  | 
26  |  | #include "libfcache_cache_value.h"  | 
27  |  | #include "libfcache_definitions.h"  | 
28  |  | #include "libfcache_libcerror.h"  | 
29  |  | #include "libfcache_types.h"  | 
30  |  |  | 
31  |  | /* Creates a cache value  | 
32  |  |  * Make sure the value cache_value is referencing, is set to NULL  | 
33  |  |  * Returns 1 if successful or -1 on error  | 
34  |  |  */  | 
35  |  | int libfcache_cache_value_initialize(  | 
36  |  |      libfcache_cache_value_t **cache_value,  | 
37  |  |      libcerror_error_t **error )  | 
38  | 126k  | { | 
39  | 126k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
40  | 126k  |   static char *function                                  = "libfcache_cache_value_initialize";  | 
41  |  |  | 
42  | 126k  |   if( cache_value == NULL )  | 
43  | 0  |   { | 
44  | 0  |     libcerror_error_set(  | 
45  | 0  |      error,  | 
46  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
47  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
48  | 0  |      "%s: invalid cache value.",  | 
49  | 0  |      function );  | 
50  |  | 
  | 
51  | 0  |     return( -1 );  | 
52  | 0  |   }  | 
53  | 126k  |   if( *cache_value != NULL )  | 
54  | 0  |   { | 
55  | 0  |     libcerror_error_set(  | 
56  | 0  |      error,  | 
57  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
58  | 0  |      LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,  | 
59  | 0  |      "%s: invalid cache value value already set.",  | 
60  | 0  |      function );  | 
61  |  | 
  | 
62  | 0  |     return( -1 );  | 
63  | 0  |   }  | 
64  | 126k  |   internal_cache_value = memory_allocate_structure(  | 
65  | 126k  |                           libfcache_internal_cache_value_t );  | 
66  |  |  | 
67  | 126k  |   if( internal_cache_value == NULL )  | 
68  | 0  |   { | 
69  | 0  |     libcerror_error_set(  | 
70  | 0  |      error,  | 
71  | 0  |      LIBCERROR_ERROR_DOMAIN_MEMORY,  | 
72  | 0  |      LIBCERROR_MEMORY_ERROR_INSUFFICIENT,  | 
73  | 0  |      "%s: unable to create cache value.",  | 
74  | 0  |      function );  | 
75  |  | 
  | 
76  | 0  |     goto on_error;  | 
77  | 0  |   }  | 
78  | 126k  |   if( memory_set(  | 
79  | 126k  |        internal_cache_value,  | 
80  | 126k  |        0,  | 
81  | 126k  |        sizeof( libfcache_internal_cache_value_t ) ) == NULL )  | 
82  | 0  |   { | 
83  | 0  |     libcerror_error_set(  | 
84  | 0  |      error,  | 
85  | 0  |      LIBCERROR_ERROR_DOMAIN_MEMORY,  | 
86  | 0  |      LIBCERROR_MEMORY_ERROR_SET_FAILED,  | 
87  | 0  |      "%s: unable to clear cache value.",  | 
88  | 0  |      function );  | 
89  |  | 
  | 
90  | 0  |     goto on_error;  | 
91  | 0  |   }  | 
92  | 126k  |   internal_cache_value->file_index = -1;  | 
93  | 126k  |   internal_cache_value->offset     = (off64_t) -1;  | 
94  |  |  | 
95  | 126k  |   *cache_value = (libfcache_cache_value_t *) internal_cache_value;  | 
96  |  |  | 
97  | 126k  |   return( 1 );  | 
98  |  |  | 
99  | 0  | on_error:  | 
100  | 0  |   if( internal_cache_value != NULL )  | 
101  | 0  |   { | 
102  | 0  |     memory_free(  | 
103  | 0  |      internal_cache_value );  | 
104  | 0  |   }  | 
105  | 0  |   return( -1 );  | 
106  | 126k  | }  | 
107  |  |  | 
108  |  | /* Frees a cache value  | 
109  |  |  * Returns 1 if successful or -1 on error  | 
110  |  |  */  | 
111  |  | int libfcache_cache_value_free(  | 
112  |  |      libfcache_cache_value_t **cache_value,  | 
113  |  |      libcerror_error_t **error )  | 
114  | 126k  | { | 
115  | 126k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
116  | 126k  |   static char *function                                  = "libfcache_cache_value_free";  | 
117  | 126k  |   int result                                             = 1;  | 
118  |  |  | 
119  | 126k  |   if( cache_value == NULL )  | 
120  | 0  |   { | 
121  | 0  |     libcerror_error_set(  | 
122  | 0  |      error,  | 
123  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
124  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
125  | 0  |      "%s: invalid cache value.",  | 
126  | 0  |      function );  | 
127  |  | 
  | 
128  | 0  |     return( -1 );  | 
129  | 0  |   }  | 
130  | 126k  |   if( *cache_value != NULL )  | 
131  | 126k  |   { | 
132  | 126k  |     internal_cache_value = (libfcache_internal_cache_value_t *) *cache_value;  | 
133  | 126k  |     *cache_value         = NULL;  | 
134  |  |  | 
135  | 126k  |     if( internal_cache_value->value != NULL )  | 
136  | 124k  |     { | 
137  | 124k  |       if( ( internal_cache_value->flags & LIBFCACHE_CACHE_VALUE_FLAG_MANAGED ) != 0 )  | 
138  | 118k  |       { | 
139  | 118k  |         if( internal_cache_value->value_free_function == NULL )  | 
140  | 0  |         { | 
141  | 0  |           libcerror_error_set(  | 
142  | 0  |            error,  | 
143  | 0  |            LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
144  | 0  |            LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,  | 
145  | 0  |            "%s: invalid cache value - missing value free function.",  | 
146  | 0  |            function );  | 
147  |  | 
  | 
148  | 0  |           result = -1;  | 
149  | 0  |         }  | 
150  | 118k  |         else if( internal_cache_value->value_free_function(  | 
151  | 118k  |             &( internal_cache_value->value ),  | 
152  | 118k  |             error ) != 1 )  | 
153  | 0  |         { | 
154  | 0  |           libcerror_error_set(  | 
155  | 0  |            error,  | 
156  | 0  |            LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
157  | 0  |            LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,  | 
158  | 0  |            "%s: unable to free value.",  | 
159  | 0  |            function );  | 
160  |  | 
  | 
161  | 0  |           result = -1;  | 
162  | 0  |         }  | 
163  | 118k  |       }  | 
164  | 124k  |     }  | 
165  | 126k  |     memory_free(  | 
166  | 126k  |      internal_cache_value );  | 
167  | 126k  |   }  | 
168  | 126k  |   return( result );  | 
169  | 126k  | }  | 
170  |  |  | 
171  |  | /* Clears the cache value  | 
172  |  |  * This function does not free the value  | 
173  |  |  * Returns 1 if successful or -1 on error  | 
174  |  |  */  | 
175  |  | int libfcache_cache_value_clear(  | 
176  |  |      libfcache_cache_value_t *cache_value,  | 
177  |  |      libcerror_error_t **error )  | 
178  | 2.01k  | { | 
179  | 2.01k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
180  | 2.01k  |   static char *function                                  = "libfcache_cache_value_free";  | 
181  |  |  | 
182  | 2.01k  |   if( cache_value == NULL )  | 
183  | 0  |   { | 
184  | 0  |     libcerror_error_set(  | 
185  | 0  |      error,  | 
186  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
187  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
188  | 0  |      "%s: invalid cache value.",  | 
189  | 0  |      function );  | 
190  |  | 
  | 
191  | 0  |     return( -1 );  | 
192  | 0  |   }  | 
193  | 2.01k  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
194  |  |  | 
195  | 2.01k  |   if( memory_set(  | 
196  | 2.01k  |        internal_cache_value,  | 
197  | 2.01k  |        0,  | 
198  | 2.01k  |        sizeof( libfcache_internal_cache_value_t ) ) == NULL )  | 
199  | 0  |   { | 
200  | 0  |     libcerror_error_set(  | 
201  | 0  |      error,  | 
202  | 0  |      LIBCERROR_ERROR_DOMAIN_MEMORY,  | 
203  | 0  |      LIBCERROR_MEMORY_ERROR_SET_FAILED,  | 
204  | 0  |      "%s: unable to clear cache value.",  | 
205  | 0  |      function );  | 
206  |  | 
  | 
207  | 0  |     return( -1 );  | 
208  | 0  |   }  | 
209  | 2.01k  |   internal_cache_value->file_index = -1;  | 
210  | 2.01k  |   internal_cache_value->offset     = (off64_t) -1;  | 
211  |  |  | 
212  | 2.01k  |   return( 1 );  | 
213  | 2.01k  | }  | 
214  |  |  | 
215  |  | /* Retrieves the cache value identifier  | 
216  |  |  * Returns 1 if successful or -1 on error  | 
217  |  |  */  | 
218  |  | int libfcache_cache_value_get_identifier(  | 
219  |  |      libfcache_cache_value_t *cache_value,  | 
220  |  |      int *file_index,  | 
221  |  |      off64_t *offset,  | 
222  |  |      int64_t *timestamp,  | 
223  |  |      libcerror_error_t **error )  | 
224  | 2.72M  | { | 
225  | 2.72M  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
226  | 2.72M  |   static char *function                                  = "libfcache_cache_value_get_identifier";  | 
227  |  |  | 
228  | 2.72M  |   if( cache_value == NULL )  | 
229  | 0  |   { | 
230  | 0  |     libcerror_error_set(  | 
231  | 0  |      error,  | 
232  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
233  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
234  | 0  |      "%s: invalid cache value.",  | 
235  | 0  |      function );  | 
236  |  | 
  | 
237  | 0  |     return( -1 );  | 
238  | 0  |   }  | 
239  | 2.72M  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
240  |  |  | 
241  | 2.72M  |   if( file_index == NULL )  | 
242  | 0  |   { | 
243  | 0  |     libcerror_error_set(  | 
244  | 0  |      error,  | 
245  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
246  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
247  | 0  |      "%s: invalid file index.",  | 
248  | 0  |      function );  | 
249  |  | 
  | 
250  | 0  |     return( -1 );  | 
251  | 0  |   }  | 
252  | 2.72M  |   if( offset == NULL )  | 
253  | 0  |   { | 
254  | 0  |     libcerror_error_set(  | 
255  | 0  |      error,  | 
256  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
257  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
258  | 0  |      "%s: invalid offset.",  | 
259  | 0  |      function );  | 
260  |  | 
  | 
261  | 0  |     return( -1 );  | 
262  | 0  |   }  | 
263  | 2.72M  |   if( timestamp == NULL )  | 
264  | 0  |   { | 
265  | 0  |     libcerror_error_set(  | 
266  | 0  |      error,  | 
267  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
268  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
269  | 0  |      "%s: invalid timestamp.",  | 
270  | 0  |      function );  | 
271  |  | 
  | 
272  | 0  |     return( -1 );  | 
273  | 0  |   }  | 
274  | 2.72M  |   *file_index = internal_cache_value->file_index;  | 
275  | 2.72M  |   *offset     = internal_cache_value->offset;  | 
276  | 2.72M  |   *timestamp  = internal_cache_value->timestamp;  | 
277  |  |  | 
278  | 2.72M  |   return( 1 );  | 
279  | 2.72M  | }  | 
280  |  |  | 
281  |  | /* Retrieves the cache value cache index  | 
282  |  |  * Returns 1 if successful or -1 on error  | 
283  |  |  */  | 
284  |  | int libfcache_cache_value_get_cache_index(  | 
285  |  |      libfcache_cache_value_t *cache_value,  | 
286  |  |      int *cache_index,  | 
287  |  |      libcerror_error_t **error )  | 
288  | 76.1k  | { | 
289  | 76.1k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
290  | 76.1k  |   static char *function                                  = "libfcache_cache_value_get_cache_index";  | 
291  |  |  | 
292  | 76.1k  |   if( cache_value == NULL )  | 
293  | 0  |   { | 
294  | 0  |     libcerror_error_set(  | 
295  | 0  |      error,  | 
296  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
297  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
298  | 0  |      "%s: invalid cache value.",  | 
299  | 0  |      function );  | 
300  |  | 
  | 
301  | 0  |     return( -1 );  | 
302  | 0  |   }  | 
303  | 76.1k  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
304  |  |  | 
305  | 76.1k  |   if( cache_index == NULL )  | 
306  | 0  |   { | 
307  | 0  |     libcerror_error_set(  | 
308  | 0  |      error,  | 
309  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
310  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
311  | 0  |      "%s: invalid cache index.",  | 
312  | 0  |      function );  | 
313  |  | 
  | 
314  | 0  |     return( -1 );  | 
315  | 0  |   }  | 
316  | 76.1k  |   *cache_index = internal_cache_value->cache_index;  | 
317  |  |  | 
318  | 76.1k  |   return( 1 );  | 
319  | 76.1k  | }  | 
320  |  |  | 
321  |  | /* Sets the cache value identifier  | 
322  |  |  * Returns 1 if successful or -1 on error  | 
323  |  |  */  | 
324  |  | int libfcache_cache_value_set_identifier(  | 
325  |  |      libfcache_cache_value_t *cache_value,  | 
326  |  |      int file_index,  | 
327  |  |      off64_t offset,  | 
328  |  |      int64_t timestamp,  | 
329  |  |      libcerror_error_t **error )  | 
330  | 202k  | { | 
331  | 202k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
332  | 202k  |   static char *function                                  = "libfcache_cache_value_set_identifier";  | 
333  |  |  | 
334  | 202k  |   if( cache_value == NULL )  | 
335  | 0  |   { | 
336  | 0  |     libcerror_error_set(  | 
337  | 0  |      error,  | 
338  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
339  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
340  | 0  |      "%s: invalid cache value.",  | 
341  | 0  |      function );  | 
342  |  | 
  | 
343  | 0  |     return( -1 );  | 
344  | 0  |   }  | 
345  | 202k  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
346  |  |  | 
347  | 202k  |   internal_cache_value->file_index = file_index;  | 
348  | 202k  |   internal_cache_value->offset     = offset;  | 
349  | 202k  |   internal_cache_value->timestamp  = timestamp;  | 
350  |  |  | 
351  | 202k  |   return( 1 );  | 
352  | 202k  | }  | 
353  |  |  | 
354  |  | /* Sets the cache value cache index  | 
355  |  |  * Returns 1 if successful or -1 on error  | 
356  |  |  */  | 
357  |  | int libfcache_cache_value_set_cache_index(  | 
358  |  |      libfcache_cache_value_t *cache_value,  | 
359  |  |      int cache_index,  | 
360  |  |      libcerror_error_t **error )  | 
361  | 126k  | { | 
362  | 126k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
363  | 126k  |   static char *function                                  = "libfcache_cache_value_set_cache_index";  | 
364  |  |  | 
365  | 126k  |   if( cache_value == NULL )  | 
366  | 0  |   { | 
367  | 0  |     libcerror_error_set(  | 
368  | 0  |      error,  | 
369  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
370  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
371  | 0  |      "%s: invalid cache value.",  | 
372  | 0  |      function );  | 
373  |  | 
  | 
374  | 0  |     return( -1 );  | 
375  | 0  |   }  | 
376  | 126k  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
377  |  |  | 
378  | 126k  |   internal_cache_value->cache_index = cache_index;  | 
379  |  |  | 
380  | 126k  |   return( 1 );  | 
381  | 126k  | }  | 
382  |  |  | 
383  |  | /* Retrieves the cache value  | 
384  |  |  * Returns 1 if successful or -1 on error  | 
385  |  |  */  | 
386  |  | int libfcache_cache_value_get_value(  | 
387  |  |      libfcache_cache_value_t *cache_value,  | 
388  |  |      intptr_t **value,  | 
389  |  |      libcerror_error_t **error )  | 
390  | 1.16M  | { | 
391  | 1.16M  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
392  | 1.16M  |   static char *function                                  = "libfcache_cache_value_get_value";  | 
393  |  |  | 
394  | 1.16M  |   if( cache_value == NULL )  | 
395  | 0  |   { | 
396  | 0  |     libcerror_error_set(  | 
397  | 0  |      error,  | 
398  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
399  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
400  | 0  |      "%s: invalid cache value.",  | 
401  | 0  |      function );  | 
402  |  | 
  | 
403  | 0  |     return( -1 );  | 
404  | 0  |   }  | 
405  | 1.16M  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
406  |  |  | 
407  | 1.16M  |   if( value == NULL )  | 
408  | 0  |   { | 
409  | 0  |     libcerror_error_set(  | 
410  | 0  |      error,  | 
411  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
412  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
413  | 0  |      "%s: invalid value.",  | 
414  | 0  |      function );  | 
415  |  | 
  | 
416  | 0  |     return( -1 );  | 
417  | 0  |   }  | 
418  | 1.16M  |   *value = internal_cache_value->value;  | 
419  |  |  | 
420  | 1.16M  |   return( 1 );  | 
421  | 1.16M  | }  | 
422  |  |  | 
423  |  | /* Sets the cache value  | 
424  |  |  * Returns 1 if successful or -1 on error  | 
425  |  |  */  | 
426  |  | int libfcache_cache_value_set_value(  | 
427  |  |      libfcache_cache_value_t *cache_value,  | 
428  |  |      intptr_t *value,  | 
429  |  |      int (*value_free_function)(  | 
430  |  |             intptr_t **value,  | 
431  |  |             libcerror_error_t **error ),  | 
432  |  |      uint8_t flags,  | 
433  |  |      libcerror_error_t **error )  | 
434  | 202k  | { | 
435  | 202k  |   libfcache_internal_cache_value_t *internal_cache_value = NULL;  | 
436  | 202k  |   static char *function                                  = "libfcache_cache_value_set_value";  | 
437  |  |  | 
438  | 202k  |   if( cache_value == NULL )  | 
439  | 0  |   { | 
440  | 0  |     libcerror_error_set(  | 
441  | 0  |      error,  | 
442  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
443  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
444  | 0  |      "%s: invalid cache value.",  | 
445  | 0  |      function );  | 
446  |  | 
  | 
447  | 0  |     return( -1 );  | 
448  | 0  |   }  | 
449  | 202k  |   internal_cache_value = (libfcache_internal_cache_value_t *) cache_value;  | 
450  |  |  | 
451  | 202k  |   if( ( flags & LIBFCACHE_CACHE_VALUE_FLAG_MANAGED ) != 0 )  | 
452  | 196k  |   { | 
453  | 196k  |     if( value_free_function == NULL )  | 
454  | 0  |     { | 
455  | 0  |       libcerror_error_set(  | 
456  | 0  |        error,  | 
457  | 0  |        LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
458  | 0  |        LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
459  | 0  |        "%s: invalid value free function.",  | 
460  | 0  |        function );  | 
461  |  | 
  | 
462  | 0  |       return( -1 );  | 
463  | 0  |     }  | 
464  | 196k  |   }  | 
465  | 202k  |   if( ( internal_cache_value->flags & LIBFCACHE_CACHE_VALUE_FLAG_MANAGED ) != 0 )  | 
466  | 76.3k  |   { | 
467  | 76.3k  |     if( internal_cache_value->value != NULL )  | 
468  | 76.3k  |     { | 
469  | 76.3k  |       if( internal_cache_value->value_free_function == NULL )  | 
470  | 0  |       { | 
471  | 0  |         libcerror_error_set(  | 
472  | 0  |          error,  | 
473  | 0  |          LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
474  | 0  |          LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,  | 
475  | 0  |          "%s: invalid cache value - missing free value function.",  | 
476  | 0  |          function );  | 
477  |  | 
  | 
478  | 0  |         return( -1 );  | 
479  | 0  |       }  | 
480  | 76.3k  |       if( internal_cache_value->value_free_function(  | 
481  | 76.3k  |            &( internal_cache_value->value ),  | 
482  | 76.3k  |            error ) != 1 )  | 
483  | 0  |       { | 
484  | 0  |         libcerror_error_set(  | 
485  | 0  |          error,  | 
486  | 0  |          LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
487  | 0  |          LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,  | 
488  | 0  |          "%s: unable to free value.",  | 
489  | 0  |          function );  | 
490  |  | 
  | 
491  | 0  |         return( -1 );  | 
492  | 0  |       }  | 
493  | 76.3k  |     }  | 
494  | 76.3k  |     internal_cache_value->flags &= ~( LIBFCACHE_CACHE_VALUE_FLAG_MANAGED );  | 
495  | 76.3k  |   }  | 
496  | 202k  |   internal_cache_value->value               = value;  | 
497  | 202k  |   internal_cache_value->value_free_function = value_free_function;  | 
498  | 202k  |   internal_cache_value->flags              |= flags;  | 
499  |  |  | 
500  | 202k  |   return( 1 );  | 
501  | 202k  | }  | 
502  |  |  |