src/sct_alloc.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Aleksander Morgado Juez                         *
00003  *   scitime@aleksander_morgado.mm.st                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "scitime.h"
00022 
00023 sct_time_ptr sct_new (void)
00024 {
00025     sct_time_ptr pNewElement = NULL;
00026 
00027     //Allocate needed memory...
00028     pNewElement = (sct_time_ptr) calloc(1, sizeof(sct_time));
00029     #ifdef SCT_DEBUG
00030     if(pNewElement == NULL)
00031     {
00032         fprintf(stderr, "[scitime:%s] >> Unable to allocate '%u' bytes for new"
00033             "element!\n", __FUNCTION__, sizeof(sct_time));
00034     }
00035     #endif
00036 
00037     return pNewElement;
00038 }
00039 
00040 sct_time_ptr sct_new_copy (sct_time_ptr pElement)
00041 {
00042     sct_time_ptr pNewElement = NULL;
00043 
00044     //Create new element...
00045     pNewElement = sct_new();
00046 
00047     //If there was no problem, copy element
00048     if(pNewElement != NULL)
00049     {
00050         memcpy(pNewElement, pElement, sizeof(*pElement));
00051     }
00052 
00053     return pNewElement;
00054 }
00055 
00056 sct_time_ptr sct_free (sct_time_ptr pElement)
00057 {
00058     free(pElement);
00059     pElement = NULL;
00060     return pElement;
00061 }

Generated on Sun May 20 15:32:42 2007 for scitime by  doxygen 1.5.1