ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Linux Sisyphus discussion list <sisyphus@lists.altlinux.org>
Subject: Re: [sisyphus] malloc behaviour
Date: Mon, 27 Nov 2006 01:44:30 +0300
Message-ID: <20061126224430.GB23346@basalt.office.altlinux.org> (raw)
In-Reply-To: <20061126222307.GA12395@rock.home>

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

On Mon, Nov 27, 2006 at 04:23:07AM +0600, Slava Semushin wrote:
> --- Michael Shigorin 2006-11-26 21:43:56 +0200
> +++ Slava Semushin 2006-11-27 04:17:57 +0600
> 
> MS> Спамит cron (точнее, sysstat):
> MS> Date: Sun, 26 Nov 2006 20:20:01 +0200 (EET)
> MS> From: root@home (Cron Daemon)
> MS> To: root@home
> MS> Subject: Cron <root@home> /usr/lib/sa/sa1 1 1
> MS> realloc: Success
> 
>     Ну так это ошибка. Мне об этой ситуации Юра Каширин рассказывал:
>     malloc()/realloc() в случае ошибки не устанавливают errno, поэтому
>     если её использовать, то могут получить вот такие результаты.

malloc(3) придерживается другого мнения:
"The Unix98 standard requires malloc(), calloc(), and realloc() to set
errno to ENOMEM upon failure.  Glibc assumes that this is done (and the
glibc versions of these routines do this); if you use a private malloc
implementation that does not set errno, then certain library routines
may fail without having a reason in errno."

>     Там код типа такого, наверное:
> 
>     ptr = realloc(...);
>     if (ptr == NULL) {
>         perror("realloc");
>         exit(1);
>     }

Для таких случаев давно придумали xrealloc.


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2006-11-26 22:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-26 19:43 [sisyphus] dist-upgrade from 3.0 log [attn: ldv] Michael Shigorin
2006-11-26 19:52 ` Valery V. Inozemtsev
2006-11-26 20:05   ` Damir Shayhutdinov
2006-11-26 21:35 ` Michael Shigorin
2006-11-26 22:00   ` Sergey
2006-11-27  9:53   ` Sergey Vlasov
2006-11-27 10:05     ` Michael Shigorin
2006-11-26 22:23 ` Slava Semushin
2006-11-26 22:22   ` Michael Shigorin
2006-11-26 22:37     ` Slava Semushin
2006-11-26 22:45       ` Slava Semushin
2006-11-26 22:51     ` [sisyphus] malloc behaviour Dmitry V. Levin
2006-11-27  9:20       ` [sisyphus] [JT] " Michael Shigorin
2006-11-26 22:44   ` Dmitry V. Levin [this message]
2006-11-27 15:30 ` [sisyphus] dist-upgrade from 3.0 log [attn: ldv] Igor Zubkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061126224430.GB23346@basalt.office.altlinux.org \
    --to=ldv@altlinux.org \
    --cc=sisyphus@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git