тесты xalloc, zalloc, zalloc_ext

This commit is contained in:
Kolan Sh 2011-07-13 17:13:47 +04:00
parent 76a2b5a904
commit 4c45d76996
3 changed files with 8 additions and 1 deletions

View File

@ -41,6 +41,8 @@ int main(int argc, char *argv[])
p[i] = NULL; p[i] = NULL;
} }
xclear(&p);
printf("Success, iterations = %lu, nobj = %lu\n", iterations, nobj); printf("Success, iterations = %lu, nobj = %lu\n", iterations, nobj);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -28,7 +28,7 @@ int main(int argc, char *argv[])
for (i = 0; i < iterations; i++) { for (i = 0; i < iterations; i++) {
idx = (size_t)(rand() % (int)nobj); idx = (size_t)(rand() % (int)nobj);
sz = i; sz = i;
p[idx] = zrealloc(p[idx], sz); zrealloc_inplace(&p[idx], sz);
if (sz && !p[idx]) { if (sz && !p[idx]) {
fprintf(stderr, "Alloc error at i = %lu\n", i); fprintf(stderr, "Alloc error at i = %lu\n", i);
@ -39,6 +39,8 @@ int main(int argc, char *argv[])
for (i = 0; i < nobj; i++) for (i = 0; i < nobj; i++)
zclear(&p[i]); zclear(&p[i]);
zclear(&p);
printf("Success, iterations = %lu, nobj = %lu\n", iterations, nobj); printf("Success, iterations = %lu, nobj = %lu\n", iterations, nobj);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -35,6 +35,8 @@ int main()
zptr4_str = zalloc_append32_str(zptr4_str, (((((('4' << 8) + '4') << 8) + '4') << 8) + '4')); zptr4_str = zalloc_append32_str(zptr4_str, (((((('4' << 8) + '4') << 8) + '4') << 8) + '4'));
puts(zptr4_str); puts(zptr4_str);
zptr3 = zalloc_append64(zptr3, 3232423423423LLU); zptr3 = zalloc_append64(zptr3, 3232423423423LLU);
zptr = zalloc_append_ptr(zptr, (void *)93842);
int64_t i64 = 1561; int64_t i64 = 1561;
int i; int i;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
@ -70,6 +72,7 @@ int main()
zptr5 = zalloc_insert64(zptr5, 9874, 5478433443LU); zptr5 = zalloc_insert64(zptr5, 9874, 5478433443LU);
zptr6_str = zalloc_insert64_str(zptr6_str, zalloc_size(zptr6_str) - 1, i64); zptr6_str = zalloc_insert64_str(zptr6_str, zalloc_size(zptr6_str) - 1, i64);
puts(zptr6_str); puts(zptr6_str);
zptr = zalloc_insert_ptr(zptr, 8, (void *)93842);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }