[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: oops? read/write vs type of length parameter

From: Paul Eggert
Subject: Re: oops? read/write vs type of length parameter
Date: Mon, 11 Apr 2011 22:06:21 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110223 Thunderbird/3.1.8

On 04/11/2011 08:01 PM, Eli Zaretskii wrote:
> When Emacs saves a buffer or some its portion,
> write-region can call emacs_write (though a_write and e_write) with
> the full extent of the region to be saved.

Ah, sorry, I missed that one.  In that case 'int'
clearly won't do for the size.

> The issue here is that emacs_write and emacs_read are on the boundary:
> they accept Emacs Lisp integers, but then call a system API.

No, they are regularly passed size_t values as sizes,
in other sections of the code.  I just now counted,
and the 16 calls to emacs_write use int constants
6 times, size_t 5 times, EMACS_INT 3 times, and an
int variable once.  So, judging by the caller's usages,
size_t would seem more appropriate.

Furthermore, the API for emacs_write should be designed
to let callers know what emacs_write should do.  Since emacs_write
operates on size values that fit into size_t, that would
seem to be the more appropriate type for its size argument.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]