Похожие чаты

0 - There is no one standard function call for

dynamic memory allocation. If I want to use calloc, I use and want to delete it from your machine, it is your decision.

1 - Tell me what is the difference between this :
char **f = (char **)calloc(1, sizeof(char *));
and this:
char **f = (char **)malloc(1 * sizeof(char *));

2 - You do not read what I wrote. He might want to be sure that all allocated memory starts with zero. Can you guarentee with that malloc? How do you know his requirements? Without req, you cannot say no reason for it.

2 ответов

10 просмотров

This is a simple split function

wait a second, i'm sorry, in first look i did not see that realloc in code so one problem does not exist anymore. so the main problem is just allocating as much as strlen and strcpy() on it which is writing + 1 outside of buffer for null terminator. also these mem allocation functions requires casting to needed type. but still 0- there is no standard because c devs want control. if you want 0 it all for no reason it's your choice, i won't waste resources for your product. 1- that's not the point. calloc is just zeroing one pointer's value in that case. the main zeroing problem starts in loop on zeroing so many unnecessary bytes also dynamically so with many bytes its a continuely hiccup until end. anyway even with few bytes, any issue more than 0 if remain on purpose shows programmer's irresponsibility which is dangerous in unseen parts of the project. if somebody want be sure that all buffers start with 0 (which is not necessary in context of this code) so will zero one first byte of it not all of it. his requirement is pretty clear in this code.

Похожие вопросы

Обсуждают сегодня

а через ESC-код ?
Alexey Kulakov
29
30500 за редактор? )
Владимир
47
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
15
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
any reference of this implementation?
BitBuddha
29
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
&"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\dumpbin.exe" /EXPORTS C:\Users\Yeet\Tauon\vcpkg\installed\x64-window...
Martin Rys
6
Карта сайта