> you are forgetting +1 for the null. you need strlen("Hello World")+1.
Heh! Yeah, true. But then the strcpy() would write into non-allocated area, so
why does the free()-call make it crash?
>
> - erik
>
>> #include <u.h>
>> #include <libc.h>
>>
>>
>> void main(int argc, char **argv) {
>> int i;
>> char *m00;
>>
>> for(i=0; i<=5; i++) {
>> if((m00 = malloc(strlen("Hello World"))) == nil) {
>> print("drama! [%d]\n",i);
>> exits("malloc");
>> }
>> strcpy(m00,"Hello World");
>> print("%d> %s\n",i,m00);
>> free(m00);
>> }
>> exits(nil);
>> }