Exemplo n.º 1
0
/******************************************************************************
 *
 * FUNCTION: void x_ipc_globalMFree(void)
 *
 * DESCRIPTION: 
 * Free memory that x_ipc allocates in the module.
 *
 *****************************************************************************/
void x_ipc_globalMFree(void)
{
  if (mGlobalp()) {
    LOCK_M_MUTEX;
    x_ipc_listFreeAllItems((LIST_FREE_FN)x_ipcFree, 
		     GET_M_GLOBAL(dataMsgBufferList));
    x_ipc_listFree(&(GET_M_GLOBAL(dataMsgBufferList)));
    GET_M_GLOBAL(dataMsgBufferList) = NULL;
    x_ipc_listFree(&(GET_M_GLOBAL(Message_Ignore_Set)));
    GET_M_GLOBAL(Message_Ignore_Set) = NULL;
    
    x_ipc_hashTableFree(&GET_M_GLOBAL(classFormatTable),
		  (HASH_ITER_FN)x_ipc_classEntryFree, NULL);
    x_ipc_hashTableFree(&GET_M_GLOBAL(formatNamesTable),
		  (HASH_ITER_FN)x_ipc_formatFreeEntry, NULL);
    x_ipc_hashTableFree(&GET_M_GLOBAL(externalFdTable),x_ipc_hashItemsFree, NULL);
    
    if (GET_M_GLOBAL(logList)[0]) {
      x_ipcFree((char *)(GET_M_GLOBAL(logList)[0])->theFile);
      x_ipcFree((char *)GET_M_GLOBAL(logList)[0]);
    }
    GET_M_GLOBAL(logList)[0] = NULL;
    if (GET_M_GLOBAL(logList)[1]) {
      x_ipcFree((char *)(GET_M_GLOBAL(logList)[1])->theFile);
      x_ipcFree((char *)GET_M_GLOBAL(logList)[1]);
    }
    GET_M_GLOBAL(logList)[1] = NULL;

    x_ipc_freeContext(&GET_M_GLOBAL(currentContext));

    x_ipc_listCleanup();
    
    x_ipc_strListFree(&GET_M_GLOBAL(requiredResources), TRUE);

    x_ipcFree((char *)GET_M_GLOBAL(modNameGlobal));

    if (GET_M_GLOBAL(byteFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(byteFormat));
    if (GET_M_GLOBAL(charFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(charFormat));
    if (GET_M_GLOBAL(shortFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(shortFormat));
    if (GET_M_GLOBAL(intFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(intFormat));
    if (GET_M_GLOBAL(longFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(longFormat));
    if (GET_M_GLOBAL(floatFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(floatFormat));
    if (GET_M_GLOBAL(doubleFormat)) x_ipc_freeFormatter(&GET_M_GLOBAL(doubleFormat));

    x_ipc_listFreeAllItems((LIST_FREE_FN)x_ipcFree, GET_M_GLOBAL(timerList));
    x_ipc_listFree(&(GET_M_GLOBAL(timerList)));

#if defined(VXWORKS)
    x_ipcFree((char *)x_ipc_gM);
    x_ipc_gM = NULL;
#else
    x_ipc_globalMInit();
    x_ipcFree((char *)GET_M_GLOBAL(currentContext));
    bzero((char *)&x_ipc_gM,sizeof(x_ipc_gM));
    x_ipc_gM_ptr = NULL;
#endif
    UNLOCK_M_MUTEX;
  }
}
Exemplo n.º 2
0
static FORMAT_PTR Enum_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  TokenPtr Token;
  FORMAT_PTR Form, subform;
  LIST_PTR format_list;
  int num_formats, i, maxVal;
  
  num_formats = 0;
  Token = NextToken(parser);
  if (Token->Type == COLON_TOK) {
    Token = NextToken(parser);
    if (Token->Type != INT_TOK) {
      *error = TRUE;
      ParserError(Token, parser, "an integer");
      return NULL;
    } else {
      maxVal = Token->value.num;
    }
  } else {
    format_list = x_ipc_listCreate();
    do {
      if (num_formats > 0) Token = NextToken(parser);
      if (Token->Type != STR_TOK) {
	*error = TRUE;
	ParserError(Token, parser, "a string");
	return NULL;
      } else {
	Form = new_n_formatter(Token->value.str);
	/* More efficient for Lisp if all enum format names are upper case */
	LOCK_M_MUTEX;
	if (IS_LISP_MODULE()) {
	  upcase(Form->formatter.name);
	}
	UNLOCK_M_MUTEX;
	x_ipc_listInsertItem((char *)Form, format_list);
	num_formats++;
      }
      Token = NextToken(parser);
    } while (Token->Type == COMMA_TOK);
    UngetToken(parser, Token);
    maxVal = num_formats - 1;
  }
  
  Form = new_a_formatter(EnumFMT, num_formats+2);
  Form->formatter.a[1].i = maxVal;
  if (num_formats > 0) {
    /* Index from high to low since "format_list" 
       has formatters in reverse order */
    subform = (FORMAT_PTR)x_ipc_listFirst(format_list);
    for(i=num_formats;i>0;i--) {
      Form->formatter.a[i+1].f = subform;
      subform = (FORMAT_PTR)x_ipc_listNext(format_list);
    }
    x_ipc_listFree(&format_list);
  }
  return Form;
}
Exemplo n.º 3
0
void x_ipc_hndDelete(HND_PTR hnd)
{
  HND_KEY_TYPE hndKey;
  LIST_PTR msgList;
  LIST_ELEM_PTR listTmp;
  MODULE_PTR module;
  MSG_PTR msg;
  
  if (hnd) {
    if (hnd->hndLanguage == UNKNOWN_LANGUAGE) return;
    
    hnd->hndLanguage = UNKNOWN_LANGUAGE;
    
    hnd->msg = NULL;
    msgList = hnd->msgList;
    hnd->msgList = NULL; /* to revent recursion of free's */
    x_ipc_listTestDeleteItemAll((LIST_ITER_FN) x_ipc_removeHndFromMsg, 
			  (char *)hnd, msgList);
    
    x_ipc_listFree(&msgList);
    
    LOCK_CM_MUTEX;
    (void)x_ipc_idTableRemove(hnd->localId, GET_C_GLOBAL(hndIdTable));
    /* Need to remove from the module list.   */
    if (GET_M_GLOBAL(moduleList) != NULL) {
      for (listTmp = GET_M_GLOBAL(moduleList)->first; 
	   (listTmp != NULL);
	   listTmp = listTmp->next
	   ) {
	module = (MODULE_PTR)(listTmp->item);
	x_ipc_listDeleteItemAll(hnd,module->hndList);
      }
    }
    if (hnd->hndData) {
      hndKey.num = hnd->sd;
      hndKey.str = hnd->hndData->hndName;
      x_ipc_hashTableRemove((char *)&hndKey, GET_C_GLOBAL(handlerTable));
      msg = GET_MESSAGE(hnd->hndData->msgName);
      if (msg) x_ipc_removeHndFromMsg(hnd, msg);
      x_ipcFree((char *)hnd->hndData->msgName);
      hnd->hndData->msgName = NULL;
      x_ipcFree((char *)hnd->hndData->hndName);
      hnd->hndData->hndName = NULL;
      x_ipcFree((char *)hnd->hndData);
      hnd->hndData = NULL;
    }
    UNLOCK_CM_MUTEX;
    hnd->hndData = NULL;
    
    x_ipcFree((char *)hnd);
  }
}
Exemplo n.º 4
0
static void x_ipc_freeContext(X_IPC_CONTEXT_PTR *context)
{
  if (!*context) return;

  x_ipcFree((char *)(*context)->servHostGlobal);
  
  x_ipc_freeContextList(&((*context)->queryNotificationList));
  x_ipc_freeContextList(&((*context)->connectNotifyList));
  x_ipc_freeContextList(&((*context)->disconnectNotifyList));
  x_ipc_freeContextList(&((*context)->changeNotifyList));
  LOCK_M_MUTEX;
  x_ipcRefFree(GET_M_GLOBAL(x_ipcRootNodeGlobal));
  GET_M_GLOBAL(x_ipcRootNodeGlobal) = NULL;
  UNLOCK_M_MUTEX;
  x_ipc_freeContextList(&((*context)->x_ipcRefFreeList));
  
  x_ipc_hashTableFree(&((*context)->moduleConnectionTable),
		      x_ipc_hashItemsFree, NULL);
  x_ipc_hashTableFree(&((*context)->handlerTable),
		      (HASH_ITER_FN) x_ipc_hndFree, NULL);
  x_ipc_hashTableFree(&((*context)->messageTable),
		      (HASH_ITER_FN) x_ipc_msgFree, NULL);
  x_ipc_hashTableFree(&((*context)->resourceTable),x_ipc_hashItemsFree, NULL);
  x_ipc_idTableFree(&(*context)->hndIdTable);
  x_ipc_idTableFree(&(*context)->msgIdTable);
  x_ipc_listFreeAllItems((LIST_FREE_FN)x_ipc_dataMsgFree,
			 (*context)->pendingReplies);
  x_ipc_listFree(&((*context)->pendingReplies));
  (*context)->pendingReplies = NULL;
  x_ipcFree((char *)(*context)->msgQueue.messages);
  initMsgQueue(&(*context)->msgQueue);
  x_ipc_strListFree(&((*context)->tappedMsgs),TRUE);
  x_ipc_strListFree(&((*context)->broadcastMsgs),TRUE);
  
  x_ipc_listFree(&((*context)->queryNotificationList));
  
  x_ipcFree((char *)*context);
  *context = NULL;
}
Exemplo n.º 5
0
static FORMAT_PTR Struct_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  FORMAT_PTR Form, subform;
  LIST_PTR format_list;
  int num_formats, i;
  
  format_list = x_ipc_listCreate();
  num_formats = 0;
  
  if (parser->TokenList->Type != RBRACE_TOK) {
    while (1) {
      x_ipc_listInsertItem((char *)Parse(parser, TRUE, error), format_list);
      num_formats++;
      if (parser->TokenList->Type == COMMA_TOK) {
	(void)NextToken(parser);
      } else if (parser->TokenList->Type == RBRACE_TOK) {
	break;
      } else {
	*error = TRUE;
	ParserError(NextToken(parser), parser, "','");
	return NULL;
      }
    }
  }
  
  Form = new_a_formatter(StructFMT, num_formats+1);
  /* Index from high to low since "format_list" 
     has formatters in reverse order */
  subform = (FORMAT_PTR)x_ipc_listFirst(format_list);
  for(i=num_formats;i>0;i--) {
    Form->formatter.a[i].f = subform;
    subform = (FORMAT_PTR)x_ipc_listNext(format_list);
  }
  
  x_ipc_listFree(&format_list);
  return Form;
}
Exemplo n.º 6
0
static void x_ipc_msgFreeMsg(MSG_PTR msg)
{
  LIST_PTR hndList;

  if (msg) {
    if (msg->direct == -1) return;
    msg->direct = -1; /* Flag that msg has already been freed */

    if ((msg)->hndList != NULL) {
      hndList = (msg)->hndList;
      (msg)->hndList = NULL;
      x_ipc_listFree(&hndList);
    }
    freeDirectList(msg);
    if (msg->msgData) {
      x_ipcFree((char *)msg->msgData->name);
      x_ipc_freeFormatter(&(msg->msgData->msgFormat));
      x_ipc_freeFormatter(&(msg->msgData->resFormat));
      x_ipcFree((char *)msg->msgData);
    }
    x_ipcFree((char *)(msg));
    msg = NULL;
  }
}
Exemplo n.º 7
0
/******************************************************************************
 *
 * FUNCTION: void x_ipc_freeContext(X_IPC_CONTEXT_PTR *context)
 *
 * DESCRIPTION: 
 * Free memory that x_ipc allocates for a context.
 *
 *****************************************************************************/
static void x_ipc_freeContextList (LIST_PTR *listPtr)
{
  x_ipc_listFreeAllItems((LIST_FREE_FN)x_ipcFree, *listPtr);
  x_ipc_listFree(listPtr);
  *listPtr = NULL;
}