char *str;
instead of writing something like str = malloc(42 * sizeof(char))
you can write str = calloc(42, sizeof(char))
and the memory allocated will be full of "zero"
> char *str;
> instead of writing something like str = malloc(42 * sizeof(char))
> you can write str = calloc(42, sizeof(char))
> and the memory allocated will be full of "zero"
--
Alcyone Systems | web http://www.alcyone.com/max/ | 971.352 Ms p.L.
San Jose, CA, US | icbm 37 20 N 121 53 W | 245 days left | &tSftDotIotE
__________________| Interstelen -- http://www.interstelen.com/
__
/ \ I thought I might never see another Saturday night.
\__/ Robert Macnamara
1. C question : redefining a new malloc() calling standard malloc()
Hello,
I am currently writing, in C (on SGI IRIX 6.4), a redefinition of
malloc(), but I would like to still be able to call the standard library
malloc().
I am looking for a way to link the all properly !
I so have the four (+1) files :
* real_malloc.h : to call the standard library malloc()
---------------
#include <stdlib.h>
void* real_malloc(size_t);
* real_malloc.c
---------------
#include "real_malloc.h"
void* real_malloc(size_t size)
{
/* Should call the standard library malloc() */
return malloc(size);
* my_malloc.h : my redefinition of malloc()
-------------
#include <stdlib.h>
void* malloc(size_t);
* my_malloc.c
--------------
#include "my_malloc.h"
#include "real_malloc.h"
void* malloc(size_t size)
{
/* some code */
void* a = real_malloc(size);
/* some code */
* essai.c : a test file
----------
#include "my_malloc.h"
main()
{
/* should call my malloc redefinition */
void* a = malloc(...);
How can I have the all correctly compile, link and WORK ???
Thanks for all response, comment, suggestion.
You can directly reply by mail.
---------------------
Xavier.
3. malloc problem ! Can malloc althought got 6 MB mem free !
4. TAR Problems
7. malloc == memory fragmentation
8. USENIX Annual Tech - Additions to Program and Savings Deadline is here
9. AIX malloc and fault tolerance - just the facts
11. how get malloc to fail with swap space