/[public]/psiconv/trunk/lib/psiconv/data.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/data.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 56 Revision 62
20#include "config.h" 20#include "config.h"
21#include "compat.h" 21#include "compat.h"
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include "data.h" 24#include "data.h"
25#include "list.h"
26#include "general.h"
27 25
28static psiconv_color clone_color(psiconv_color color); 26static psiconv_color clone_color(psiconv_color color);
29static psiconv_font clone_font(psiconv_font font); 27static psiconv_font clone_font(psiconv_font font);
30static psiconv_border clone_border(psiconv_border border); 28static psiconv_border clone_border(psiconv_border border);
31static psiconv_bullet clone_bullet(psiconv_bullet bullet); 29static psiconv_bullet clone_bullet(psiconv_bullet bullet);
135 &no_border, /* bottom_border */ 133 &no_border, /* bottom_border */
136 &tabs, /* tabs */ 134 &tabs, /* tabs */
137 }; 135 };
138 psiconv_paragraph_layout res; 136 psiconv_paragraph_layout res;
139 137
140 pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s)); 138 if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s))))
139 return NULL;
141 res = psiconv_clone_paragraph_layout(&pl); 140 res = psiconv_clone_paragraph_layout(&pl);
142 psiconv_list_free(pl.tabs->extras); 141 psiconv_list_free(pl.tabs->extras);
143 return res; 142 return res;
144} 143}
145 144
146psiconv_color clone_color(psiconv_color color) 145psiconv_color clone_color(psiconv_color color)
147{ 146{
148 psiconv_color result; 147 psiconv_color result;
149 result = malloc(sizeof(*result)); 148 if (!(result = malloc(sizeof(*result))))
149 return NULL;
150 *result = *color; 150 *result = *color;
151 return result; 151 return result;
152} 152}
153 153
154psiconv_font clone_font(psiconv_font font) 154psiconv_font clone_font(psiconv_font font)
155{ 155{
156 psiconv_font result; 156 psiconv_font result;
157 result = malloc(sizeof(*result)); 157 if(!(result = malloc(sizeof(*result))))
158 goto ERROR1;
158 *result = *font; 159 *result = *font;
159 result->name = strdup(result->name); 160 if (!(result->name = strdup(result->name)))
161 goto ERROR2;
160 return result; 162 return result;
163ERROR2:
164 free(result);
165ERROR1:
166 return NULL;
161} 167}
162 168
163psiconv_border clone_border(psiconv_border border) 169psiconv_border clone_border(psiconv_border border)
164{ 170{
165 psiconv_border result; 171 psiconv_border result;
166 result = malloc(sizeof(*result)); 172 if (!(result = malloc(sizeof(*result))))
173 goto ERROR1;
167 *result = *border; 174 *result = *border;
168 result->color = clone_color(result->color); 175 if(!(result->color = clone_color(result->color)))
176 goto ERROR2;
169 return result; 177 return result;
178ERROR2:
179 free(result);
180ERROR1:
181 return NULL;
170} 182}
171 183
172psiconv_bullet clone_bullet(psiconv_bullet bullet) 184psiconv_bullet clone_bullet(psiconv_bullet bullet)
173{ 185{
174 psiconv_bullet result; 186 psiconv_bullet result;
175 result = malloc(sizeof(*result)); 187 if (!(result = malloc(sizeof(*result))))
188 goto ERROR1;
176 *result = *bullet; 189 *result = *bullet;
177 result->font = clone_font(result->font); 190 if (!(result->font = clone_font(result->font)))
191 goto ERROR2;
178 result->color = clone_color(result->color); 192 if (!(result->color = clone_color(result->color)))
193 goto ERROR3;
179 return result; 194 return result;
195ERROR3:
196 psiconv_free_font(result->font);
197ERROR2:
198 free(result);
199ERROR1:
200 return NULL;
180} 201}
181 202
182psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) 203psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs)
183{ 204{
184 psiconv_all_tabs result; 205 psiconv_all_tabs result;
185 result = malloc(sizeof(*result)); 206 if (!(result = malloc(sizeof(*result))))
207 goto ERROR1;
186 *result = *all_tabs; 208 *result = *all_tabs;
187 result->extras = psiconv_list_clone(result->extras); 209 if (!(result->extras = psiconv_list_clone(result->extras)))
210 goto ERROR2;
188 return result; 211 return result;
212ERROR2:
213 free(result);
214ERROR1:
215 return NULL;
189} 216}
190 217
191psiconv_character_layout psiconv_clone_character_layout 218psiconv_character_layout psiconv_clone_character_layout
192 (psiconv_character_layout ls) 219 (psiconv_character_layout ls)
193{ 220{
194 psiconv_character_layout result; 221 psiconv_character_layout result;
195 222
196 result = malloc(sizeof(*result)); 223 if (!(result = malloc(sizeof(*result))))
224 goto ERROR1;
197 *result = *ls; 225 *result = *ls;
198 result->color = clone_color(result->color); 226 if (!(result->color = clone_color(result->color)))
227 goto ERROR2;
199 result->back_color = clone_color(result->back_color); 228 if (!(result->back_color = clone_color(result->back_color)))
229 goto ERROR3;
200 result->font = clone_font(result->font); 230 if (!(result->font = clone_font(result->font)))
231 goto ERROR4;
201 return result; 232 return result;
233ERROR4:
234 psiconv_free_color(result->back_color);
235ERROR3:
236 psiconv_free_color(result->color);
237ERROR2:
238 free(result);
239ERROR1:
240 return NULL;
202} 241}
203 242
204psiconv_paragraph_layout psiconv_clone_paragraph_layout 243psiconv_paragraph_layout psiconv_clone_paragraph_layout
205 (psiconv_paragraph_layout ls) 244 (psiconv_paragraph_layout ls)
206{ 245{
207 psiconv_paragraph_layout result; 246 psiconv_paragraph_layout result;
208 247
209 result = malloc(sizeof(*result)); 248 if (!(result = malloc(sizeof(*result))))
249 goto ERROR1;
210 *result = *ls; 250 *result = *ls;
211 result->back_color = clone_color(result->back_color); 251 if (!(result->back_color = clone_color(result->back_color)))
252 goto ERROR2;
212 result->bullet = clone_bullet(result->bullet); 253 if (!(result->bullet = clone_bullet(result->bullet)))
254 goto ERROR3;
213 result->left_border = clone_border(result->left_border); 255 if (!(result->left_border = clone_border(result->left_border)))
256 goto ERROR4;
214 result->right_border = clone_border(result->right_border); 257 if (!(result->right_border = clone_border(result->right_border)))
258 goto ERROR5;
215 result->top_border = clone_border(result->top_border); 259 if (!(result->top_border = clone_border(result->top_border)))
260 goto ERROR6;
216 result->bottom_border = clone_border(result->bottom_border); 261 if (!(result->bottom_border = clone_border(result->bottom_border)))
262 goto ERROR7;
217 result->tabs = clone_all_tabs(result->tabs); 263 if (!(result->tabs = clone_all_tabs(result->tabs)))
264 goto ERROR8;
218 return result; 265 return result;
266ERROR8:
267 psiconv_free_border(result->bottom_border);
268ERROR7:
269 psiconv_free_border(result->top_border);
270ERROR6:
271 psiconv_free_border(result->right_border);
272ERROR5:
273 psiconv_free_border(result->left_border);
274ERROR4:
275 psiconv_free_bullet(result->bullet);
276ERROR3:
277 psiconv_free_color(result->back_color);
278ERROR2:
279 free(result);
280ERROR1:
281 return NULL;
219} 282}
220 283
221psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) 284psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr)
222{ 285{
223 if (nr == 0) 286 if (nr == 0)

Legend:
Removed from v.56  
changed lines
  Added in v.62

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26