Re: avoiding strdup()

Liste des GroupesRevenir à cl c  
Sujet : Re: avoiding strdup()
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c
Date : 11. Mar 2024, 20:29:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240311202914.00005cab@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 
An application that cares will fsync(2) the file descriptor before
closing it with close(2) and will check the fsync return value and
take appropriate action if it fails.
 
While I personally eschew fopen/fclose and their ilk due to
performance overhead generally, were I to use it for data which
is required to be valid, I'd always check the results of fflush
before closing with fclose().

Last I looked at it, and it was several years ago, so can misremember,
fflush() is only slightly better, if at all better, than fclose(). It
also does not guarantee that my data propagated beyond filesystem write
cache.
For fsync() there are problems as well.
(1) - it is not part of C Standard.
(2) - even on systems where it is implemented, like Linux, BSD and
Mac, it is likely to not do the same things.
(3) - if done in UI thread, it's likely to negatively affect
responsiveness of UI. If not done in UI thread, it's too much of
error-prone code to write.

 
It really depends on the application and the importance of the
data (ephemeral data, e.g. terminal output from ps(1), may not
require the same level of scrutiny as a database, for example).



Date Sujet#  Auteur
7 Mar 24 * Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"51Ben
9 Mar 24 `* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"50Blue-Maned_Hawk
9 Mar 24  +* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"5Keith Thompson
9 Mar 24  i`* Re: [OT] UTF-8 sig. Was: "White House to Developers: Using C or C++ Invites Cybersecurity Risks"4Blue-Maned_Hawk
9 Mar 24  i `* Re: [OT] UTF-8 sig.3vallor
10 Mar 24  i  `* Re: [OT] UTF-8 sig.2Blue-Maned_Hawk
21 Mar 24  i   `- Re: [OT] UTF-8 sig.1Anton Shepelev
9 Mar 24  `* Re: [OT] UTF-8 sig.44Ben
9 Mar 24   +* Re: [OT] UTF-8 sig.3Richard Harnden
10 Mar 24   i`* Re: [OT] UTF-8 sig.2Ben Bacarisse
10 Mar 24   i `- Re: [OT] UTF-8 sig.1Richard Harnden
9 Mar 24   +* Re: [OT] UTF-8 sig.7Blue-Maned_Hawk
9 Mar 24   i`* Re: [OT] UTF-8 sig.6Richard Harnden
10 Mar 24   i +- Re: [OT] UTF-8 sig.1Blue-Maned_Hawk
10 Mar 24   i `* Re: [OT] UTF-8 sig.4Ben Bacarisse
10 Mar 24   i  `* Re: [OT] UTF-8 sig.3Michael S
10 Mar 24   i   +- Re: [OT] UTF-8 sig.1Blue-Maned_Hawk
10 Mar 24   i   `- Re: [OT] UTF-8 sig.1Kaz Kylheku
9 Mar 24   `* avoiding strdup() (was: Re: [OT] UTF-8 sig.)33vallor
9 Mar 24    +- Re: avoiding strdup()1Spiros Bousbouras
10 Mar 24    +* Re: avoiding strdup()30Keith Thompson
10 Mar 24    i`* Re: avoiding strdup()29Michael S
10 Mar 24    i +- Re: avoiding strdup()1Blue-Maned_Hawk
10 Mar 24    i `* Re: avoiding strdup()27Kaz Kylheku
10 Mar 24    i  +- Re: avoiding strdup()1Richard Harnden
11 Mar 24    i  +* Re: avoiding strdup()22Malcolm McLean
11 Mar 24    i  i+* Re: avoiding strdup()10Michael S
11 Mar 24    i  ii+* Re: avoiding strdup()6Keith Thompson
11 Mar 24    i  iii+* Re: avoiding strdup()2Kaz Kylheku
11 Mar 24    i  iiii`- Re: avoiding strdup()1Keith Thompson
11 Mar 24    i  iii+- Re: avoiding strdup()1Keith Thompson
11 Mar 24    i  iii`* Re: avoiding strdup()2Spiros Bousbouras
11 Mar 24    i  iii `- Re: avoiding strdup()1Keith Thompson
11 Mar 24    i  ii`* Re: avoiding strdup()3Michael S
11 Mar 24    i  ii +- Re: avoiding strdup()1Michael S
11 Mar 24    i  ii `- Re: avoiding strdup()1Spiros Bousbouras
11 Mar 24    i  i+* Re: avoiding strdup()3Kaz Kylheku
11 Mar 24    i  ii`* Re: avoiding strdup()2Richard Kettlewell
11 Mar 24    i  ii `- Re: avoiding strdup()1Keith Thompson
12 Mar 24    i  i`* Re: avoiding strdup()8Malcolm McLean
12 Mar 24    i  i `* Re: avoiding strdup()7Keith Thompson
12 Mar 24    i  i  +* Re: avoiding strdup()3Malcolm McLean
13 Mar 24    i  i  i`* Re: avoiding strdup()2Keith Thompson
13 Mar 24    i  i  i `- Re: avoiding strdup()1Malcolm McLean
13 Mar 24    i  i  `* Re: avoiding strdup()3Malcolm McLean
13 Mar 24    i  i   `* Re: avoiding strdup()2James Kuyper
13 Mar 24    i  i    `- Re: avoiding strdup()1David Brown
29 Apr 24    i  `* Re: avoiding strdup()3Lawrence D'Oliveiro
29 Apr 24    i   `* Re: avoiding strdup()2i
1 May 24    i    `- Re: avoiding strdup()1steve
10 Mar 24    `- Re: avoiding strdup()1Richard Harnden

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal