projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
malloc周辺を中心としたリファクタリング
[YACASL2.git]
/
src
/
cerr.c
diff --git
a/src/cerr.c
b/src/cerr.c
index
3f7887b
..
db5ca2f
100644
(file)
--- a/
src/cerr.c
+++ b/
src/cerr.c
@@
-13,6
+13,18
@@
void *malloc_chk(size_t size, char *tag)
return p;
}
return p;
}
+/* malloc_chkを実行してメモリを確保してから、 */
+/* コピーした文字列を返す */
+char *strdup_chk(const char *s, char *tag)
+{
+ assert(s != NULL);
+ char *t;
+
+ t = malloc_chk(strlen(s) + 1, tag);
+ strcpy(t, s);
+ return t;
+}
+
/* 現在のエラー */
CERR *cerr;
/* 現在のエラー */
CERR *cerr;