• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Mem_Free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Mem_Free函数的典型用法代码示例。如果您正苦于以下问题:C++ Mem_Free函数的具体用法?C++ Mem_Free怎么用?C++ Mem_Free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Mem_Free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Cmd_GetConfigList

/*
=====================================
Cmd_GetConfigList

Prints or complete .cfg filename
=====================================
*/
qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
{
	search_t		*t;
	string		matchbuf;
	int		i, numconfigs;

	t = FS_Search( va( "%s*.cfg", s ), true, false );
	if( !t ) return false;

	Q_strncpy( matchbuf, t->filenames[0], 256 );
	if( completedname && length ) Q_strncpy( completedname, matchbuf, length );
	if( t->numfilenames == 1 ) return true;

	for( i = 0, numconfigs = 0; i < t->numfilenames; i++ )
	{
		const char *ext = FS_FileExtension( t->filenames[i] );

		if( Q_stricmp( ext, "cfg" )) continue;
		Q_strncpy( matchbuf, t->filenames[i], 256 );
		Msg( "%16s\n", matchbuf );
		numconfigs++;
	}

	Msg( "\n^3 %i configs found.\n", numconfigs );
	Mem_Free( t );

	// cut shortestMatch to the amount common with s
	if( completedname && length )
	{
		for( i = 0; matchbuf[i]; i++ )
		{
			if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
				completedname[i] = 0;
		}
	}

	return true;
}
开发者ID:GAMELASTER,项目名称:xash3d,代码行数:45,代码来源:con_utils.c


示例2: Cmd_GetSavesList

/*
=====================================
Cmd_GetSavesList

Prints or complete savegame filename
=====================================
*/
qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
{
	search_t		*t;
	string		matchbuf;
	int		i, numsaves;

	t = FS_Search( va( "save/%s*.sav", s ), true, true );	// lookup only in gamedir
	if( !t ) return false;

	FS_FileBase( t->filenames[0], matchbuf ); 
	if( completedname && length ) Q_strncpy( completedname, matchbuf, length );
	if( t->numfilenames == 1 ) return true;

	for( i = 0, numsaves = 0; i < t->numfilenames; i++ )
	{
		const char *ext = FS_FileExtension( t->filenames[i] ); 

		if( Q_stricmp( ext, "sav" )) continue;
		FS_FileBase( t->filenames[i], matchbuf );
		Msg( "%16s\n", matchbuf );
		numsaves++;
	}

	Msg( "\n^3 %i saves found.\n", numsaves );
	Mem_Free( t );

	// cut shortestMatch to the amount common with s
	if( completedname && length )
	{
		for( i = 0; matchbuf[i]; i++ )
		{
			if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
				completedname[i] = 0;
		}
	}

	return true;
}
开发者ID:GAMELASTER,项目名称:xash3d,代码行数:45,代码来源:con_utils.c


示例3: R_LoadImage

/*
=============================
idGameBustOutWindow::LoadBoardFiles
=============================
*/
void idGameBustOutWindow::LoadBoardFiles( void ) {
	int i;
	int w,h;
	ID_TIME_T time;
	int boardSize;
	byte *currentBoard;

	if ( boardDataLoaded ) {
		return;
	}

	boardSize = 9 * 12 * 4;
	levelBoardData = (byte*)Mem_Alloc( boardSize * numLevels );

	currentBoard = levelBoardData;

	for ( i=0; i<numLevels; i++ ) {
		byte *pic;
		idStr	name = "guis/assets/bustout/level";
		name += (i+1);
		name += ".tga";

		R_LoadImage( name, &pic, &w, &h, &time, false );

		if ( pic != NULL ) {
			if ( w != 9 || h != 12 ) {
				common->DWarning( "Hell Bust-Out level image not correct dimensions! (%d x %d)", w, h );
			}

			memcpy( currentBoard, pic, boardSize );
			Mem_Free(pic);
		}

		currentBoard += boardSize;
	}

	boardDataLoaded = true;
}
开发者ID:iodoom-gitorious,项目名称:windowshasyous-dhewg-iodoom3,代码行数:43,代码来源:GameBustOutWindow.cpp


示例4: SW_VES_deconstruct

void SW_VES_deconstruct(void)
{
	OutPeriod pd;
	IntU i;

	// De-allocate parameters
	if (SW_VegEstab.count > 0)
	{
		for (i = 0; i < SW_VegEstab.count; i++)
		{
			Mem_Free(SW_VegEstab.parms[i]);
			SW_VegEstab.parms[i] = NULL;
		}

		Mem_Free(SW_VegEstab.parms);
		SW_VegEstab.parms = NULL;
	}


	ForEachOutPeriod(pd)
	{
		// De-allocate days and parameters
		if (SW_VegEstab.count > 0)
		{
			if (!isnull(SW_VegEstab.p_oagg[pd]->days)) {
				Mem_Free(SW_VegEstab.p_oagg[eSW_Year]->days);
			}

			if (!isnull(SW_VegEstab.p_accu[pd]->days)) {
				Mem_Free(SW_VegEstab.p_accu[eSW_Year]->days);
			}
		}

		// De-allocate output structures
		if (pd > eSW_Day && !isnull(SW_VegEstab.p_oagg[pd])) {
			Mem_Free(SW_VegEstab.p_oagg[pd]);
			SW_VegEstab.p_oagg[pd] = NULL;
		}

		if (!isnull(SW_VegEstab.p_accu[pd])) {
			Mem_Free(SW_VegEstab.p_accu[pd]);
			SW_VegEstab.p_accu[pd] = NULL;
		}
	}
}
开发者ID:Burke-Lauenroth-Lab,项目名称:SOILWAT,代码行数:45,代码来源:SW_VegEstab.c


示例5: FS_LoadFile

static unsigned char *decode_image(downloadinfo *di, const char *content_type)
{
	unsigned char *pixels = NULL;
	fs_offset_t filesize = 0;
	unsigned char *data = FS_LoadFile(di->filename, tempmempool, true, &filesize);
	if(data)
	{
		int mip = 0;
		if(!strcmp(content_type, "image/jpeg"))
			pixels = JPEG_LoadImage_BGRA(data, filesize, &mip);
		else if(!strcmp(content_type, "image/png"))
			pixels = PNG_LoadImage_BGRA(data, filesize, &mip);
		else if(filesize >= 7 && !strncmp((char *) data, "\xFF\xD8", 7))
			pixels = JPEG_LoadImage_BGRA(data, filesize, &mip);
		else if(filesize >= 7 && !strncmp((char *) data, "\x89PNG\x0D\x0A\x1A\x0A", 7))
			pixels = PNG_LoadImage_BGRA(data, filesize, &mip);
		else
			Con_Printf("Did not detect content type: %s\n", content_type);
		Mem_Free(data);
	}
	// do we call Image_MakeLinearColorsFromsRGB or not?
	return pixels;
}
开发者ID:CyberSys,项目名称:darkplaces,代码行数:23,代码来源:libcurl.c


示例6: disk_read

DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count)
{
    void *buffer;

    u32 len;
    s32 ret = 0;

    /* Buffer length */
    len = (count * SECTOR_SZ);

    /* Allocate buffer */
    buffer = Mem_Alloc(count * 512);
    if (!buffer)
        return RES_ERROR;

    /* Read sectors */
    switch (drv) {
    case DRIVE_SDHC:
        /* Read SD sectors */
        ret = sdio_ReadSectors(sector, count, buffer);
        break;

    case DRIVE_EHCI:
        /* Read USB sectors */
        ret = ehci_ReadSectors(sector, count, buffer);
        break;
    }

    /* Copy buffer */
    if (ret)
        memcpy(buff, buffer, len);

    /* Free buffer */
    Mem_Free(buffer);

    return (ret) ? RES_OK : RES_ERROR;
}
开发者ID:shadowbladeZ,项目名称:fat-module,代码行数:37,代码来源:diskio.c


示例7: FreeXprt

void FreeXprt(SVCXPRT *xprt)
{
  if(!xprt)
    {
      LogFullDebug(COMPONENT_RPC,
                   "Attempt to free NULL xprt");
      return;
      
    }

  LogFullDebug(COMPONENT_RPC,
               "FreeXprt xprt=%p", xprt);
  if(xprt->xp_ops == &Svcudp_op)
    {
      xp_free(Su_data(xprt));
      xp_free(rpc_buffer(xprt));
    }
  else if (xprt->xp_ops == &Svctcp_op)
    {
      struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
      XDR_DESTROY(&(cd->xdrs));
      xp_free(xprt->xp_p1); /* cd */
    }
  else if (xprt->xp_ops == &Svctcp_rendezvous_op)
    {
      xp_free(xprt->xp_p1); /* r */
    }
  else
    {
      LogCrit(COMPONENT_RPC,
              "Attempt to free unknown xprt %p",
              xprt);
      return;
    }

  Mem_Free(xprt);
}
开发者ID:MeghanaM,项目名称:nfs-ganesha,代码行数:37,代码来源:Svc_tcp_oncrpc.c


示例8: Host_Exec_f

/*
===============
Host_Exec_f
===============
*/
void Host_Exec_f( void )
{
	string	cfgpath;
	char	*f;

	if( Cmd_Argc() != 2 )
	{
		Msg( "Usage: exec <filename>\n" );
		return;
	}

	// HACKHACK: don't execute listenserver.cfg in singleplayer
	if( !Q_stricmp( Cvar_VariableString( "lservercfgfile" ),  Cmd_Argv( 1 )))
	{
		if( Cvar_VariableValue( "maxplayers" ) == 1.0f )
			return;
	}

	Q_strncpy( cfgpath, Cmd_Argv( 1 ), sizeof( cfgpath )); 
	FS_DefaultExtension( cfgpath, ".cfg" ); // append as default

	f = (char *)FS_LoadFile( cfgpath, NULL, false );
	if( !f )
	{
		MsgDev( D_NOTE, "couldn't exec %s\n", Cmd_Argv( 1 ));
		return;
	}

	MsgDev( D_INFO, "execing %s\n", Cmd_Argv( 1 ));

	// terminate the string with newline just in case it's missing
	// insertion order is backwards from execution order
	Cbuf_InsertText( "\n" );
	Cbuf_InsertText( f );
	Mem_Free( f );
}
开发者ID:ptitSeb,项目名称:xash3d,代码行数:41,代码来源:host.c


示例9: Mem_Free

/*
================
idDemoFile::Close
================
*/
void idDemoFile::Close() {
	if ( writing && compressor ) {
		compressor->FinishCompress();
	}

	if ( f ) {
		fileSystem->CloseFile( f );
		f = NULL;
	}
	if ( fLog ) {
		fileSystem->CloseFile( fLog );
		fLog = NULL;
	}
	if ( fileImage ) {
		Mem_Free( fileImage );
		fileImage = NULL;
	}
	if ( compressor ) {
		delete compressor;
		compressor = NULL;
	}

	demoStrings.DeleteContents( true );
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:29,代码来源:DemoFile.cpp


示例10: POSIXFSAL_closedir

/**
 * FSAL_closedir :
 * Free the resources allocated for reading directory entries.
 *     
 * \param dir_descriptor (input):
 *        Pointer to a directory descriptor filled by FSAL_opendir.
 * 
 * \return Major error codes :
 *        - ERR_FSAL_NO_ERROR     (no error)
 *        - Another error code if an error occured.
 */
fsal_status_t POSIXFSAL_closedir(fsal_dir_t * dir_descriptor     /* IN */  )
{
  posixfsal_dir_t * p_dir_descriptor = (posixfsal_dir_t *) dir_descriptor;
  int rc;

  /* sanity checks */
  if(!p_dir_descriptor)
    Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_closedir);

#ifdef _USE_POSIXDB_READDIR_BLOCK
  if(p_dir_descriptor->p_dbentries)
    Mem_Free(p_dir_descriptor->p_dbentries);
#endif

  rc = closedir(p_dir_descriptor->p_dir);
  if(rc != 0)
    Return(posix2fsal_error(errno), errno, INDEX_FSAL_closedir);

  /* fill dir_descriptor with zeros */
  memset(p_dir_descriptor, 0, sizeof(posixfsal_dir_t));

  Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_closedir);

}
开发者ID:MeghanaM,项目名称:nfs-ganesha,代码行数:35,代码来源:fsal_dirs.c


示例11: Delta_Shutdown

void Delta_Shutdown( void )
{
	int	i;

	if( !delta_init ) return;

	for( i = 0; i < NUM_FIELDS( dt_info ); i++ )
	{
		dt_info[i].numFields = 0;
		dt_info[i].customEncode = CUSTOM_NONE;
		dt_info[i].userCallback = NULL;
		dt_info[i].funcName[0] = '\0';

		if( dt_info[i].pFields )
		{
			Mem_Free( dt_info[i].pFields );
			dt_info[i].pFields = NULL;
		}

		dt_info[i].bInitialized = false;
	}

	delta_init = false;
}
开发者ID:THE-Swank,项目名称:xash3d,代码行数:24,代码来源:net_encode.c


示例12: Netchan_FragSend

/* <65aeb> ../engine/net_chan.c:1123 */
void Netchan_FragSend(netchan_t *chan)
{
	fragbufwaiting_t *wait;
	int i;

	if (!chan)
		return;

	for (i = 0; i < MAX_STREAMS; i++)
	{
		// Already something queued up, just leave in waitlist
		if (chan->fragbufs[i])
		{
			continue;
		}

		wait = chan->waitlist[i];

		// Nothing to queue?
		if (!wait)
		{
			continue;
		}

		chan->waitlist[i] = wait->next;

		wait->next = NULL;

		// Copy in to fragbuf
		chan->fragbufs[i] = wait->fragbufs;
		chan->fragbufcount[i] = wait->fragbufcount;

		// Throw away wait list
		Mem_Free(wait);
	}
}
开发者ID:omertelli,项目名称:rehlds,代码行数:37,代码来源:net_chan.cpp


示例13: WriteTGA24

static void WriteTGA24 (const char *filename, const byte * data, int width, int height, int offset)
{
	int i, size;
	byte *buffer;
	qFILE file;

	size = width * height * 3;
	/* allocate a buffer and set it up */
	buffer = (byte *)Mem_Alloc(size + TGA_HEADER_SIZE);
	memset(buffer, 0, TGA_HEADER_SIZE);
	buffer[2] = 2;
	buffer[12] = width & 255;
	buffer[13] = width >> 8;
	buffer[14] = height & 255;
	buffer[15] = height >> 8;
	buffer[16] = 24;
	/* create top-down TGA */
	buffer[17] = 32;

	/* swap rgb to bgr */
	for (i = 0; i < size; i += 3) {
		buffer[i + TGA_HEADER_SIZE] = data[i*2 + offset + 2];	/* blue */
		buffer[i + TGA_HEADER_SIZE + 1] = data[i*2 + offset + 1];	/* green */
		buffer[i + TGA_HEADER_SIZE + 2] = data[i*2 + offset + 0];	/* red */
	}

	/* write it and free the buffer */
	if (FS_OpenFile(filename, &file, FILE_WRITE) > 0)
		Sys_Error("Unable to open %s for writing", filename);

	FS_Write(buffer, size + TGA_HEADER_SIZE, &file);

	/* close the file */
	FS_CloseFile(&file);
	Mem_Free(buffer);
}
开发者ID:kevlund,项目名称:ufoai,代码行数:36,代码来源:lightmap.c


示例14: SCR_LoadCreditsFont

static void SCR_LoadCreditsFont( void )
{
	byte	*buffer;
	size_t	length;
	int	fontWidth;
	qfont_t	*src;

	// setup creditsfont
	if( !FS_FileExists( "gfx/creditsfont.fnt", false ))
		return;

	// half-life font with variable chars witdh
	buffer = FS_LoadFile( "gfx/creditsfont.fnt", &length, false );
	R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
	
	if( buffer && length >= sizeof( qfont_t ))
	{
		int	i;
	
		src = (qfont_t *)buffer;
		clgame.scrInfo.iCharHeight = src->rowheight;

		// build rectangles
		for( i = 0; i < 256; i++ )
		{
			cls.creditsFont.fontRc[i].left = (word)src->fontinfo[i].startoffset % fontWidth;
			cls.creditsFont.fontRc[i].right = cls.creditsFont.fontRc[i].left + src->fontinfo[i].charwidth;
			cls.creditsFont.fontRc[i].top = (word)src->fontinfo[i].startoffset / fontWidth;
			cls.creditsFont.fontRc[i].bottom = cls.creditsFont.fontRc[i].top + src->rowheight;
			clgame.scrInfo.charWidths[i] = src->fontinfo[i].charwidth;
		}
		cls.creditsFont.valid = true;
	}

	if( buffer ) Mem_Free( buffer );
}
开发者ID:bmk10,项目名称:sing-engine,代码行数:36,代码来源:cl_scrn.c


示例15: Key_SetBinding

/**
 * @brief Bind a keynum to script command
 * @param[in] keynum Converted from string to keynum
 * @param[in] binding The script command to bind keynum to
 * @param[in] space The key space to bind the key for (menu, game or battle)
 * @sa Key_Bind_f
 * @sa Key_StringToKeynum
 * @note If command is empty, this function will only remove the actual key binding instead of setting empty string.
 */
void Key_SetBinding (int keynum, const char *binding, keyBindSpace_t space)
{
	char **keySpace = NULL;

	if (keynum == -1 || keynum >= K_KEY_SIZE)
		return;

	Com_DPrintf(DEBUG_CLIENT, "Binding for '%s' for space ", binding);
	switch (space) {
	case KEYSPACE_UI:
		keySpace = &menuKeyBindings[keynum];
		Com_DPrintf(DEBUG_CLIENT, "menu\n");
		break;
	case KEYSPACE_GAME:
		keySpace = &keyBindings[keynum];
		Com_DPrintf(DEBUG_CLIENT, "game\n");
		break;
	case KEYSPACE_BATTLE:
		keySpace = &battleKeyBindings[keynum];
		Com_DPrintf(DEBUG_CLIENT, "battle\n");
		break;
	default:
		Com_DPrintf(DEBUG_CLIENT, "failure\n");
		return;
	}

	/* free old bindings */
	if (*keySpace) {
		Mem_Free(*keySpace);
		*keySpace = NULL;
	}

	/* allocate memory for new binding, but don't set empty commands*/
	if (binding)
		*keySpace = Mem_PoolStrDup(binding, com_genericPool, 0);
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:45,代码来源:cl_keys.c


示例16: Netchan_CopyNormalFragments

/*
==============================
Netchan_CopyNormalFragments

==============================
*/
qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg )
{
	fragbuf_t	*p, *n;

	if( !chan->incomingready[FRAG_NORMAL_STREAM] )
		return false;

	if( !chan->incomingbufs[FRAG_NORMAL_STREAM] )
	{
		MsgDev( D_ERROR, "Netchan_CopyNormalFragments:  Called with no fragments readied\n" );
		chan->incomingready[FRAG_NORMAL_STREAM] = false;
		return false;
	}

	p = chan->incomingbufs[FRAG_NORMAL_STREAM];

	BF_Init( msg, "NetMessage", net_message_buffer, sizeof( net_message_buffer ));

	while( p )
	{
		n = p->next;
		
		// copy it in
		BF_WriteBits( msg, BF_GetData( &p->frag_message ), BF_GetNumBitsWritten( &p->frag_message ));

		Mem_Free( p );
		p = n;
	}
	
	chan->incomingbufs[FRAG_NORMAL_STREAM] = NULL;

	// reset flag
	chan->incomingready[FRAG_NORMAL_STREAM] = false;

	return true;
}
开发者ID:ShaunNoWay,项目名称:xash3d,代码行数:42,代码来源:net_chan.c


示例17: VID_StartupGamma

void VID_StartupGamma( void )
{
	// Device supports gamma anyway, but cannot do anything with it.
	fs_offset_t	gamma_size;
	byte	*savedGamma;
	size_t	gammaTypeSize = sizeof(glState.stateRamp);

	// init gamma ramp
	Q_memset( glState.stateRamp, 0, gammaTypeSize);

#if defined(XASH_SDL)
	glConfig.deviceSupportsGamma = !SDL_GetWindowGammaRamp( host.hWnd, NULL, NULL, NULL);
#endif

	if( !glConfig.deviceSupportsGamma )
	{
		// force to set cvar
		Cvar_FullSet( "gl_ignorehwgamma", "1", CVAR_GLCONFIG );
		MsgDev( D_ERROR, "VID_StartupGamma: hardware gamma unsupported\n");
	}

	if( gl_ignorehwgamma->integer )
	{
		glConfig.deviceSupportsGamma = false;	// even if supported!
		BuildGammaTable( vid_gamma->value, vid_texgamma->value );
		MsgDev( D_NOTE, "VID_StartupGamma: software gamma initialized\n" );
		return;
	}

	// share this extension so engine can grab them
	GL_SetExtension( GL_HARDWARE_GAMMA_CONTROL, glConfig.deviceSupportsGamma );

	savedGamma = FS_LoadFile( "gamma.dat", &gamma_size, false );

	if( !savedGamma || gamma_size != (fs_offset_t)gammaTypeSize)
	{
		// saved gamma not found or corrupted file
		FS_WriteFile( "gamma.dat", glState.stateRamp, gammaTypeSize);
		MsgDev( D_NOTE, "VID_StartupGamma: gamma.dat initialized\n" );
		if( savedGamma ) Mem_Free( savedGamma );
	}
	else
	{
		GL_BuildGammaTable();

		// validate base gamma
		if( !Q_memcmp( savedGamma, glState.stateRamp, gammaTypeSize))
		{
			// all ok, previous gamma is valid
			MsgDev( D_NOTE, "VID_StartupGamma: validate screen gamma - ok\n" );
		}
		else if( !Q_memcmp( glState.gammaRamp, glState.stateRamp, gammaTypeSize))
		{
			// screen gamma is equal to render gamma (probably previous instance crashed)
			// run additional check to make sure for it
			if( Q_memcmp( savedGamma, glState.stateRamp, gammaTypeSize))
			{
				// yes, current gamma it's totally wrong, restore it from gamma.dat
				MsgDev( D_NOTE, "VID_StartupGamma: restore original gamma after crash\n" );
				Q_memcpy( glState.stateRamp, savedGamma, gammaTypeSize);
			}
			else
			{
				// oops, savedGamma == glState.stateRamp == glState.gammaRamp
				// probably r_gamma set as default
				MsgDev( D_NOTE, "VID_StartupGamma: validate screen gamma - disabled\n" ); 
			}
		}
		else if( !Q_memcmp( glState.gammaRamp, savedGamma, gammaTypeSize))
		{
			// saved gamma is equal render gamma, probably gamma.dat wroted after crash
			// run additional check to make sure it
			if( Q_memcmp( savedGamma, glState.stateRamp, gammaTypeSize))
			{
				// yes, saved gamma it's totally wrong, get origianl gamma from screen
				MsgDev( D_NOTE, "VID_StartupGamma: merge gamma.dat after crash\n" );
				FS_WriteFile( "gamma.dat", glState.stateRamp, gammaTypeSize);
			}
			else
			{
				// oops, savedGamma == glState.stateRamp == glState.gammaRamp
				// probably r_gamma set as default
				MsgDev( D_NOTE, "VID_StartupGamma: validate screen gamma - disabled\n" ); 
			}
		}
		else
		{
			// current gamma unset by other application, so we can restore it here
			MsgDev( D_NOTE, "VID_StartupGamma: restore original gamma after crash\n" );
			Q_memcpy( glState.stateRamp, savedGamma, gammaTypeSize);
		}

		Mem_Free( savedGamma );
	}

	vid_gamma->modified = true;
}
开发者ID:DeadZoneLuna,项目名称:xash3d,代码行数:97,代码来源:gl_vidnt.c


示例18: Cmd_Exec_f

/* <5e43> ../engine/cmd.c:347 */
void Cmd_Exec_f(void)
{
	const char *pszFileName;
	const char *pszFileExt;
	char *pszFileData;
	int nAddLen;
	FileHandle_t hFile;

	if (Cmd_Argc() != 2)
	{
		Con_Printf("exec <filename> : execute a script file\n");
		return;
	}

	pszFileName = Cmd_Argv(1);
	if (!pszFileName || pszFileName[0] == 0)
	{
		return;
	}

	if (Q_strstr(pszFileName, "\\")
		|| Q_strstr(pszFileName, ":")
		|| Q_strstr(pszFileName, "~")
		|| Q_strstr(pszFileName, "..")
		|| *pszFileName == '/')
	{
		Con_Printf("exec %s: invalid path.\n", pszFileName);
		return;
	}

	pszFileExt = COM_FileExtension((char *)pszFileName);
	if (Q_stricmp(pszFileExt, "cfg") && Q_stricmp(pszFileExt, "rc"))
	{
		Con_Printf("exec %s: not a .cfg or .rc file\n", pszFileName);
		return;
	}

	hFile = FS_OpenPathID(pszFileName, "rb", "GAMECONFIG");
	if (!hFile)
	{
		hFile = FS_OpenPathID(pszFileName, "rb", "GAME");
	}
	if (!hFile)
	{
		hFile = FS_Open(pszFileName, "rb");
	}

	if (!hFile)
	{
		if (!Q_strstr(pszFileName, "autoexec.cfg")
			&& !Q_strstr(pszFileName, "userconfig.cfg")
			&& !Q_strstr(pszFileName, "hw/opengl.cfg")
			&& !Q_strstr(pszFileName, "joystick.cfg")
			&& !Q_strstr(pszFileName, "game.cfg"))
		{
			Con_Printf("couldn't exec %s\n", pszFileName);
		}

		return;
	}

	nAddLen = FS_Size(hFile);
	pszFileData = (char *)Mem_Malloc(nAddLen + 1);

	if (!pszFileData)
	{
		Con_Printf("exec: not enough space for %s", pszFileName);
		FS_Close(hFile);
		return;
	}

	FS_Read(pszFileData, nAddLen, 1, hFile);
	pszFileData[nAddLen] = 0;
	FS_Close(hFile);

	Con_DPrintf("execing %s\n", pszFileName);

	if (cmd_text.cursize + nAddLen + 2 < cmd_text.maxsize)
	{
		Cbuf_InsertTextLines(pszFileData);
	}
	else
	{
		char *pszDataPtr = pszFileData;
		while (true)
		{
			Cbuf_Execute();	// TODO: This doesn't obey the rule to first execute commands from the file, and then the others in the buffer
			pszDataPtr = COM_ParseLine(pszDataPtr);

			if (com_token[0] == 0)
			{
				break;
			}

			Cbuf_InsertTextLines(com_token);
		}
	}

	Mem_Free(pszFileData);
//.........这里部分代码省略.........
开发者ID:LeninChan,项目名称:rehlds,代码行数:101,代码来源:cmd.cpp


示例19: Sys_ListFiles

/*
================
Sys_ListFiles
================
*/
int Sys_ListFiles( const char* directory, const char* extension, idStrList& list )
{
	struct dirent* d;
	DIR* fdir;
	bool dironly = false;
	char search[MAX_OSPATH];
	struct stat st;
	bool debug;
	
	list.Clear();
	
	debug = cvarSystem->GetCVarBool( "fs_debug" );
	// DG: we use fnmatch for shell-style pattern matching
	// so the pattern should at least contain "*" to match everything,
	// the extension will be added behind that (if !dironly)
	idStr pattern( "*" );
	
	// passing a slash as extension will find directories
	if( extension[0] == '/' && extension[1] == 0 )
	{
		dironly = true;
	}
	else
	{
		// so we have *<extension>, the same as in the windows code basically
		pattern += extension;
	}
	// DG end
	
	// NOTE: case sensitivity of directory path can screw us up here
	if( ( fdir = opendir( directory ) ) == NULL )
	{
		if( debug )
		{
			common->Printf( "Sys_ListFiles: opendir %s failed\n", directory );
		}
		return -1;
	}
	
	// DG: use readdir_r instead of readdir for thread safety
	// the following lines are from the readdir_r manpage.. fscking ugly.
	int nameMax = pathconf( directory, _PC_NAME_MAX );
	if( nameMax == -1 )
		nameMax = 255;
	int direntLen = offsetof( struct dirent, d_name ) + nameMax + 1;
	
	struct dirent* entry = ( struct dirent* )Mem_Alloc( direntLen, TAG_CRAP );
	
	if( entry == NULL )
	{
		common->Warning( "Sys_ListFiles: Mem_Alloc for entry failed!" );
		closedir( fdir );
		return 0;
	}
	
	while( readdir_r( fdir, entry, &d ) == 0 && d != NULL )
	{
		// DG end
		idStr::snPrintf( search, sizeof( search ), "%s/%s", directory, d->d_name );
		if( stat( search, &st ) == -1 )
			continue;
		if( !dironly )
		{
			// DG: the original code didn't work because d3 bfg abuses the extension
			// to match whole filenames and patterns in the savegame-code, not just file extensions...
			// so just use fnmatch() which supports matching shell wildcard patterns ("*.foo" etc)
			// if we should ever need case insensitivity, use FNM_CASEFOLD as third flag
			if( fnmatch( pattern.c_str(), d->d_name, 0 ) != 0 )
				continue;
			// DG end
		}
		if( ( dironly && !( st.st_mode & S_IFDIR ) ) ||
				( !dironly && ( st.st_mode & S_IFDIR ) ) )
			continue;
			
		list.Append( d->d_name );
	}
	
	closedir( fdir );
	Mem_Free( entry );
	
	if( debug )
	{
		common->Printf( "Sys_ListFiles: %d entries in %s\n", list.Num(), directory );
	}
	
	return list.Num();
}
开发者ID:bubble8773,项目名称:RBDOOM-3-BFG,代码行数:93,代码来源:posix_main.cpp


示例20: nfs_read_core_conf


//.........这里部分代码省略.........
          pparam->program[P_RQUOTA] = atoi(key_value);
#endif
        }
      else if(!strcasecmp(key_name, "NFS_Protocols"))
        {

#     define MAX_NFSPROTO      10       /* large enough !!! */
#     define MAX_NFSPROTO_LEN  256      /* so is it !!! */

          char *nfsvers_list[MAX_NFSPROTO];
          int idx, count;

          /* reset nfs versions flags (clean defaults) */
          pparam->core_options &= ~(CORE_OPTION_ALL_VERS);

          /* allocate nfs vers strings */
          for(idx = 0; idx < MAX_NFSPROTO; idx++)
            nfsvers_list[idx] = (char *)Mem_Alloc(MAX_NFSPROTO_LEN);

          /*
           * Search for coma-separated list of nfsprotos
           */
          count = nfs_ParseConfLine(nfsvers_list, MAX_NFSPROTO,
                                    key_value, find_comma, find_endLine);

          if(count < 0)
            {
              LogCrit(COMPONENT_CONFIG,
                      "NFS_Protocols list too long (>%d)",
                      MAX_NFSPROTO);

              /* free sec strings */
              for(idx = 0; idx < MAX_NFSPROTO; idx++)
                Mem_Free((caddr_t) nfsvers_list[idx]);

              return -1;
            }

          /* add each Nfs protocol flag to the option field.  */

          for(idx = 0; idx < count; idx++)
            {
              if(!strcmp(nfsvers_list[idx], "4"))
                {
                  pparam->core_options |= CORE_OPTION_NFSV4;
                }
/* only NFSv4 is supported for the FSAL_PROXY */
#if ! defined( _USE_PROXY ) || defined ( _HANDLE_MAPPING )
              else if(!strcmp(nfsvers_list[idx], "2"))
                {
                  pparam->core_options |= CORE_OPTION_NFSV2;
                }
              else if(!strcmp(nfsvers_list[idx], "3"))
                {
                  pparam->core_options |= CORE_OPTION_NFSV3;
                }
#endif                          /* _USE_PROXY */
              else
                {
                  LogCrit(COMPONENT_CONFIG,
                          "Invalid NFS Protocol \"%s\". Values can be: 2, 3, 4.",
                          nfsvers_list[idx]);
                  return -1;
                }
            }
开发者ID:phdeniel-at-home,项目名称:nfs-ganesha,代码行数:66,代码来源:nfs_read_conf.c



注:本文中的Mem_Free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mem_Init函数代码示例发布时间:2022-05-30
下一篇:
C++ Mem_Alloc函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap