Example #1
0
MgErr resize_CalloutAccumulator(CalloutAccumulator ***arr, size_t elements)
{
    MgErr lv_err;
    size_t sz;

    if (arr == NULL || *arr == NULL || **arr == NULL)
        return mgArgErr;

    FTW_COMPILER_ASSERT(sizeof(struct ftw_pcre_callout_data) == 8 * sizeof(int32));
    FTW_COMPILER_ASSERT(sizeof(CalloutAccumulator) == sizeof(int32) + sizeof(struct ftw_pcre_callout_data));
    FTW_COMPILER_ASSERT(Offset(CalloutAccumulator, element) == 4);
    sz = Offset(CalloutAccumulator, element) + sizeof(struct ftw_pcre_callout_data) * elements;
    lv_err = DSSetHandleSize(*arr, sz);
    
    if (lv_err == mgNoErr)
        (**arr)->dimsize = (int32)elements;

    return lv_err;
}
void LVException::populateErrorCluster(lvError * err) {
	std::string debugInfo;
	err->code = m_code;
	err->status = true;

	if (m_debug){
		debugInfo = "<<DEBUGINFO: File=";
		debugInfo += m_file;
		debugInfo += " Line=";
		debugInfo += std::to_string(m_line);
		debugInfo += ">> ";
		m_messageLength += debugInfo.size();
	}

	// Check if the existing string handle is valid.
	if (DSCheckHandle(err->source) == mgNoErr) {
		// Handle valid: Check if it needs to be resized
		if ((m_messageLength + sizeof(int32_t)) > DSGetHandleSize(err->source)) {
			DSSetHandleSize(err->source, sizeof(int32_t) + m_messageLength);
		}
	}
	else {
		// Handle invalid: Create a new string handle
		err->source = (LStrHandle)DSNewHandle(sizeof(int32_t) + m_messageLength);
	}
	if (m_debug) {
		// Move the string data (with debug info)
		debugInfo += this->what();
		MoveBlock(debugInfo.c_str(), (*err->source)->str, m_messageLength);
	}
	else {
		// Move the string data (without debug info)
		MoveBlock(this->what(), (*err->source)->str, m_messageLength);
	}

	// Set the string length variable
	(*err->source)->cnt = static_cast<int32>(m_messageLength);
}