x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
newstr.c - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\DarkPuzzle\libs\bullet_sdk\jam-2.5\newstr.c
旋转
特效
属性
历史版本
/* * Copyright 1993, 1995 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ /* * newstr.c - string manipulation routines * * To minimize string copying, string creation, copying, and freeing * is done through newstr. * * External functions: * * newstr() - return a malloc'ed copy of a string * copystr() - return a copy of a string previously returned by newstr() * freestr() - free a string returned by newstr() or copystr() * donestr() - free string tables * * Once a string is passed to newstr(), the returned string is readonly. * * This implementation builds a hash table of all strings, so that multiple * calls of newstr() on the same string allocate memory for the string once. * Strings are never actually freed. * * 11/04/02 (seiwald) - const-ing for string literals */ # include "jam.h" # include "newstr.h" # include "hash.h" typedef const char *STRING; static struct hash *strhash = 0; static int strtotal = 0; /* * newstr() - return a malloc'ed copy of a string */ const char * newstr( const char *string ) { STRING str, *s = &str; if( !strhash ) strhash = hashinit( sizeof( STRING ), "strings" ); *s = string; if( hashenter( strhash, (HASHDATA **)&s ) ) { int l = strlen( string ); char *m = (char *)malloc( l + 1 ); if (DEBUG_MEM) printf("newstr: allocating %d bytes\n", l + 1 ); strtotal += l + 1; memcpy( m, string, l + 1 ); *s = m; } return *s; } /* * copystr() - return a copy of a string previously returned by newstr() */ const char * copystr( const char *s ) { return s; } /* * freestr() - free a string returned by newstr() or copystr() */ void freestr( const char *s ) { } /* * donestr() - free string tables */ void donestr() { hashdone( strhash ); if( DEBUG_MEM ) printf( "%dK in strings\n", strtotal / 1024 ); }
newstr.c
网页地址
文件地址
上一页
47/73
下一页
下载
( 1 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.