• R/O
  • SSH
  • HTTPS

cstl: コミット


コミットメタ情報

リビジョン409 (tree)
日時2010-10-07 22:49:16
作者katono

ログメッセージ

文字列用メモリプール追加。

変更サマリ

差分

--- branches/try-vfunc/unittest/LibcImpl.h (revision 408)
+++ branches/try-vfunc/unittest/LibcImpl.h (revision 409)
@@ -41,11 +41,17 @@
4141 # include <stdlib.h>
4242 # define MALLOC malloc
4343 # define FREE free
44+# define STR_MALLOC malloc
45+# define STR_FREE free
4446 #else
4547 # define MALLOC LibcImpl_malloc
4648 # define FREE LibcImpl_free
49+# define STR_MALLOC LibcImpl_str_malloc
50+# define STR_FREE LibcImpl_str_free
4751 void *LibcImpl_malloc(size_t size);
4852 void LibcImpl_free(void *ptr);
53+char *LibcImpl_str_malloc(size_t size);
54+void LibcImpl_str_free(char *ptr);
4955 #endif
5056
5157
--- branches/try-vfunc/unittest/LibcImpl.c (revision 408)
+++ branches/try-vfunc/unittest/LibcImpl.c (revision 409)
@@ -251,6 +251,28 @@
251251 if (!ptr) return;
252252 ((TestAssertionBlock *) ptr)->used_flag = 0;
253253 }
254+
255+#define STR_POOL_SIZE 4096
256+static char str_pool[STR_POOL_SIZE];
257+static const char *str_pool_end_ptr = &str_pool[STR_POOL_SIZE];
258+static char *str_pool_next_ptr = str_pool;
259+
260+char *LibcImpl_str_malloc(size_t size)
261+{
262+ char *p = str_pool_next_ptr;
263+ if (str_pool_next_ptr + size > str_pool_end_ptr) {
264+ return 0;
265+ }
266+ str_pool_next_ptr += size;
267+ return p;
268+}
269+
270+void LibcImpl_str_free(char *ptr)
271+{
272+ (void) ptr;
273+ str_pool_next_ptr = str_pool;
274+}
275+
254276 #endif
255277
256278
旧リポジトリブラウザで表示