--- libaitsess/src/sess.c 2012/07/22 22:13:48 1.5 +++ libaitsess/src/sess.c 2013/01/17 13:10:49 1.5.4.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: sess.c,v 1.5 2012/07/22 22:13:48 misho Exp $ +* $Id: sess.c,v 1.5.4.1 2013/01/17 13:10:49 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -44,7 +44,6 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF TH SUCH DAMAGE. */ #include "global.h" -#include "aitsess.h" /* @@ -63,8 +62,8 @@ sess_FreeValues(char *** __restrict ppsVals) return; for (ptr = *ppsVals; *ptr; ptr++) - io_free(*ptr); - io_free(*ppsVals); + e_free(*ptr); + e_free(*ppsVals); *ppsVals = NULL; } @@ -84,7 +83,7 @@ sess_GetValues(ait_sess_t * __restrict s, char ***ppsV if (!s || !ppsVals) return -1; - valz = io_malloc(sizeof(caddr_t)); + valz = e_malloc(sizeof(caddr_t)); if (!valz) { LOGERR; return -1; @@ -92,10 +91,10 @@ sess_GetValues(ait_sess_t * __restrict s, char ***ppsV *valz = NULL; // allocated memory & mirrored shared memory into this - Shared = io_malloc(s->eom); + Shared = e_malloc(s->eom); if (!Shared) { LOGERR; - io_free(valz); + e_free(valz); return -1; } else memcpy(Shared, s->addr, s->eom); @@ -107,18 +106,18 @@ sess_GetValues(ait_sess_t * __restrict s, char ***ppsV else i++; - valz = io_realloc(valz, (i + 1) * sizeof(caddr_t)); + valz = e_realloc(valz, (i + 1) * sizeof(caddr_t)); if (!valz) { LOGERR; - io_free(Shared); + e_free(Shared); return -1; } else valz[i] = NULL; - valz[i - 1] = io_strdup(peer); + valz[i - 1] = e_strdup(peer); } - io_free(Shared); + e_free(Shared); *ppsVals = valz; return i; } @@ -151,7 +150,7 @@ sess_GetValue(ait_sess_t * __restrict s, const char *c } // allocated memory & mirrored shared memory into this - Shared = io_malloc(s->eom); + Shared = e_malloc(s->eom); if (!Shared) { LOGERR; return -1; @@ -171,12 +170,12 @@ sess_GetValue(ait_sess_t * __restrict s, const char *c } else def = IS_DEF; - io_free(Shared); + e_free(Shared); return i | def; } } - io_free(Shared); + e_free(Shared); return 0; } @@ -203,16 +202,16 @@ sess_DelValue(ait_sess_t * __restrict s, const char *c strlcpy(szAttr, csAttr, sizeof szAttr); strlcat(szAttr, "=", sizeof szAttr); - Buffer = io_malloc(s->eom); + Buffer = e_malloc(s->eom); if (!Buffer) { LOGERR; return -1; } else memset(Buffer, 0, s->eom); - Shared = io_malloc(s->eom); + Shared = e_malloc(s->eom); if (!Shared) { LOGERR; - io_free(Buffer); + e_free(Buffer); return -1; } else { DEC_SEM(s); @@ -236,8 +235,8 @@ sess_DelValue(ait_sess_t * __restrict s, const char *c msync(s->addr, 0, MS_SYNC | MS_INVALIDATE); INC_SEM(s); - io_free(Shared); - io_free(Buffer); + e_free(Shared); + e_free(Buffer); return 0; } @@ -265,16 +264,16 @@ sess_SetValue(ait_sess_t * __restrict s, const char *c strlcpy(szAttr, csAttr, sizeof szAttr); strlcat(szAttr, "=", sizeof szAttr); - Buffer = io_malloc(s->eom); + Buffer = e_malloc(s->eom); if (!Buffer) { LOGERR; return -1; } else memset(Buffer, 0, s->eom); - Shared = io_malloc(s->eom); + Shared = e_malloc(s->eom); if (!Shared) { LOGERR; - io_free(Buffer); + e_free(Buffer); return -1; } else { DEC_SEM(s); @@ -320,8 +319,8 @@ sess_SetValue(ait_sess_t * __restrict s, const char *c msync(s->addr, 0, MS_SYNC | MS_INVALIDATE); INC_SEM(s); - io_free(Shared); - io_free(Buffer); + e_free(Shared); + e_free(Buffer); return upd | def; } @@ -364,7 +363,7 @@ sess_prepareSession(ait_sess_t * __restrict s, char us DEC_SEM(s); s->zcpy = useDirect; - arr = io_map2vars(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t), + arr = ait_map2vars(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t), hdr->hdr_argc, useDirect); INC_SEM(s); @@ -390,10 +389,10 @@ sess_doneSession(ait_sess_t * __restrict s, array_t ** } if (!s->zcpy) - io_arrayFree(*arr); + array_Free(*arr); else DETACH_MEMORY(s); - io_arrayDestroy(arr); + array_Destroy(arr); } /* @@ -423,9 +422,10 @@ sess_commitSession(ait_sess_t * __restrict s, array_t hdr = (sess_hdr_t*) s->addr; DEC_SEM(s); - if ((ret = io_vars2map(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t), arr)) != -1) { + if ((ret = ait_vars2map(s->addr + sizeof(sess_hdr_t), + s->eom - sizeof(sess_hdr_t), arr)) != -1) { hdr->hdr_magic = SESS_AIT_MAGIC; - hdr->hdr_argc = io_arraySize(arr); + hdr->hdr_argc = array_Size(arr); ret += sizeof(sess_hdr_t); } INC_SEM(s);