nfs-ganesha 1.4
|
00001 /* 00002 * Various libcidr memory-related functions 00003 */ 00004 #ifdef HAVE_CONFIG_H 00005 #include "config.h" 00006 #endif 00007 00008 #include <errno.h> 00009 #include <stdlib.h> 00010 #include <string.h> 00011 00012 #include "abstract_mem.h" 00013 #include "cidr.h" 00014 00015 00016 /* Allocate a struct cidr_addr */ 00017 CIDR * 00018 cidr_alloc(void) 00019 { 00020 CIDR *toret; 00021 00022 toret = gsh_malloc(sizeof(CIDR)); 00023 if(toret==NULL) 00024 { 00025 errno = ENOMEM; 00026 return(NULL); 00027 } 00028 memset(toret, 0, sizeof(CIDR)); 00029 00030 return(toret); 00031 } 00032 00033 00034 /* Duplicate a CIDR */ 00035 CIDR * 00036 cidr_dup(const CIDR *src) 00037 { 00038 CIDR *toret; 00039 00040 toret = cidr_alloc(); 00041 if(toret==NULL) 00042 return(NULL); /* Preserve errno */ 00043 memcpy(toret, src, sizeof(CIDR)); 00044 00045 return(toret); 00046 } 00047 00048 00049 /* Free a struct cidr_addr */ 00050 void 00051 cidr_free(CIDR *tofree) 00052 { 00053 gsh_free(tofree); 00054 }