* clear out some warnings by gcc 9.3.1.
[alpine.git] / pith / body.c
blob541b0bbec4ca8c05396fadca7daff1a5eb7a71ea
1 /*
2 * ========================================================================
3 * Copyright 2013-2020 Eduardo Chappa
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
14 #include "../pith/headers.h"
15 #include "../pith/body.h"
16 #include "../pith/smime.h"
17 #include "../pith/ical.h"
19 void *
20 create_body_sparep(SpareType stype, void *s)
22 BODY_SPARE_S *rv;
24 rv = fs_get(sizeof(BODY_SPARE_S));
25 rv->sptype = stype;
26 rv->data = s;
27 return (void *) rv;
30 SpareType
31 get_body_sparep_type(void *s)
33 return ((BODY_SPARE_S *)s)->sptype;
36 void *
37 get_body_sparep_data(void *s)
39 return ((BODY_SPARE_S *)s)->data;
42 void
43 free_body_sparep(void **sparep)
45 char *s;
46 SIZEDTEXT *st;
47 VCALENDAR_S *vcal;
49 if(sparep && *sparep){
50 switch(get_body_sparep_type(*sparep)){
51 #ifdef SMIME
52 case P7Type: PKCS7_free((PKCS7 *) get_body_sparep_data(*sparep));
53 break;
54 #endif /* SMIME */
55 case CharType: s = (char *)get_body_sparep_data(*sparep);
56 fs_give((void **) &s);
57 break;
58 case SizedText: st = (SIZEDTEXT *)get_body_sparep_data(*sparep);
59 fs_give((void **) &st->data);
60 fs_give((void **) &st);
61 break;
62 case iCalType: vcal = (VCALENDAR_S *)get_body_sparep_data(*sparep);
63 ical_free_vcalendar((void **) &vcal);
64 break;
65 default : break;
67 ((BODY_SPARE_S *)(*sparep))->data = NULL;
68 fs_give(sparep);