| 1 | /* |
| 2 | * Copyright 2009 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * "Daniel Kopecek" <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #include <config.h> |
| 24 | #include "public/sexp.h" |
| 25 | #include "_seap-error.h" |
| 26 | |
| 27 | SEAP_err_t *SEAP_error_new(void) |
| 28 | { |
| 29 | SEAP_err_t *e = malloc(sizeof(SEAP_err_t)); |
| 30 | |
| 31 | e->id = 0; |
| 32 | e->code = 0; |
| 33 | e->type = 0; |
| 34 | e->data = NULL; |
| 35 | |
| 36 | return (e); |
| 37 | } |
| 38 | |
| 39 | SEAP_err_t *SEAP_error_clone(SEAP_err_t *e) |
| 40 | { |
| 41 | SEAP_err_t *n = SEAP_error_new(); |
| 42 | |
| 43 | n->id = e->id; |
| 44 | n->code = e->code; |
| 45 | n->type = e->type; |
| 46 | n->data = e->data ? SEXP_ref(e->data) : NULL; |
| 47 | |
| 48 | return (n); |
| 49 | } |
| 50 | |
| 51 | void SEAP_error_free(SEAP_err_t *e) |
| 52 | { |
| 53 | if (e->data == NULL) |
| 54 | SEXP_free(e->data); |
| 55 | free(e); |
| 56 | return; |
| 57 | } |