Skip to content

Commit

Permalink
Merge pull request #2266 from chu11/headers_memory_alloc
Browse files Browse the repository at this point in the history
Update zlist/zlistx header comments to indicate memory exhaustion not possible error
  • Loading branch information
sphaero committed Aug 24, 2023
2 parents 1f14c25 + 2937c0e commit b588b95
Show file tree
Hide file tree
Showing 26 changed files with 83 additions and 100 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5138,13 +5138,13 @@ This is the class interface:
zlist_item (zlist_t *self);

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
CZMQ_EXPORT int
zlist_append (zlist_t *self, void *item);

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
CZMQ_EXPORT int
zlist_push (zlist_t *self, void *item);
Expand Down Expand Up @@ -5389,13 +5389,13 @@ This is the class interface:

// Add an item to the head of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
CZMQ_EXPORT void *
zlistx_add_start (zlistx_t *self, void *item);

// Add an item to the tail of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
CZMQ_EXPORT void *
zlistx_add_end (zlistx_t *self, void *item);

Expand Down Expand Up @@ -5500,8 +5500,7 @@ This is the class interface:
// duplicator, if any, on the item. If low_value is true, starts searching
// from the start of the list, otherwise searches from the end. Use the item
// comparator, if any, to find where to place the new node. Returns a handle
// to the new node, or NULL if memory was exhausted. Resets the cursor to the
// list head.
// to the new node. Resets the cursor to the list head.
CZMQ_EXPORT void *
zlistx_insert (zlistx_t *self, void *item, bool low_value);

Expand Down
11 changes: 5 additions & 6 deletions api/python_cffi.slurp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,13 +1693,13 @@ void *
zlist_item (zlist_t *self);

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
int
zlist_append (zlist_t *self, void *item);

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
int
zlist_push (zlist_t *self, void *item);
Expand Down Expand Up @@ -1790,13 +1790,13 @@ zlistx_t *

// Add an item to the head of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
void *
zlistx_add_start (zlistx_t *self, void *item);

// Add an item to the tail of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
void *
zlistx_add_end (zlistx_t *self, void *item);

Expand Down Expand Up @@ -1901,8 +1901,7 @@ void
// duplicator, if any, on the item. If low_value is true, starts searching
// from the start of the list, otherwise searches from the end. Use the item
// comparator, if any, to find where to place the new node. Returns a handle
// to the new node, or NULL if memory was exhausted. Resets the cursor to the
// list head.
// to the new node. Resets the cursor to the list head.
void *
zlistx_insert (zlistx_t *self, void *item, bool low_value);

Expand Down
4 changes: 2 additions & 2 deletions api/zlist.api
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@

<method name = "append">
Append an item to the end of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
<argument name = "item" type = "anything" />
<return type = "integer" />
</method>

<method name = "push">
Push an item to the start of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
<argument name = "item" type = "anything" />
<return type = "integer" />
Expand Down
7 changes: 3 additions & 4 deletions api/zlistx.api
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<method name = "add_start">
Add an item to the head of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
<argument name = "item" type = "anything" mutable = "1" />
<return type = "anything" mutable = "1" />
</method>

<method name = "add_end">
Add an item to the tail of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
<argument name = "item" type = "anything" mutable = "1" />
<return type = "anything" mutable = "1" />
</method>
Expand Down Expand Up @@ -175,8 +175,7 @@
duplicator, if any, on the item. If low_value is true, starts searching
from the start of the list, otherwise searches from the end. Use the item
comparator, if any, to find where to place the new node. Returns a handle
to the new node, or NULL if memory was exhausted. Resets the cursor to the
list head.
to the new node. Resets the cursor to the list head.
<argument name = "item" type = "anything" mutable = "1" />
<argument name = "low_value" type = "boolean" />
<return type = "anything" mutable = "1" />
Expand Down
15 changes: 7 additions & 8 deletions bindings/delphi/CZMQ.pas
Original file line number Diff line number Diff line change
Expand Up @@ -935,12 +935,12 @@ interface
function Item: Pointer;

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function Append(Item: Pointer): Integer;

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function Push(Item: Pointer): Integer;

Expand Down Expand Up @@ -1004,12 +1004,12 @@ interface

// Add an item to the head of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
function AddStart(Item: Pointer): Pointer;

// Add an item to the tail of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
function AddEnd(Item: Pointer): Pointer;

// Return the number of items in the list
Expand Down Expand Up @@ -1091,8 +1091,7 @@ interface
// duplicator, if any, on the item. If low_value is true, starts searching
// from the start of the list, otherwise searches from the end. Use the item
// comparator, if any, to find where to place the new node. Returns a handle
// to the new node, or NULL if memory was exhausted. Resets the cursor to the
// list head.
// to the new node. Resets the cursor to the list head.
function Insert(Item: Pointer; LowValue: Boolean): Pointer;

// Move an item, specified by handle, into position in a sorted list. Uses
Expand Down Expand Up @@ -3685,12 +3684,12 @@ TZlist = class(TInterfacedObject, IZlist)
function Item: Pointer;

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function Append(Item: Pointer): Integer;

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function Push(Item: Pointer): Integer;

Expand Down
11 changes: 5 additions & 6 deletions bindings/delphi/libczmq.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1380,12 +1380,12 @@ interface
function zlist_item(self: PZlist): Pointer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function zlist_append(self: PZlist; Item: Pointer): Integer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
function zlist_push(self: PZlist; Item: Pointer): Integer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

Expand Down Expand Up @@ -1477,12 +1477,12 @@ interface

// Add an item to the head of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
function zlistx_add_start(self: PZlistx; Item: Pointer): Pointer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Add an item to the tail of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
function zlistx_add_end(self: PZlistx; Item: Pointer): Pointer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Return the number of items in the list
Expand Down Expand Up @@ -1568,8 +1568,7 @@ interface
// duplicator, if any, on the item. If low_value is true, starts searching
// from the start of the list, otherwise searches from the end. Use the item
// comparator, if any, to find where to place the new node. Returns a handle
// to the new node, or NULL if memory was exhausted. Resets the cursor to the
// list head.
// to the new node. Resets the cursor to the list head.
function zlistx_insert(self: PZlistx; Item: Pointer; LowValue: Boolean): Pointer; cdecl; external lib_czmq {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Move an item, specified by handle, into position in a sorted list. Uses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public long item () {
}
/*
Append an item to the end of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
*/
native static int __append (long self, long item);
Expand All @@ -103,7 +103,7 @@ public int append (long item) {
}
/*
Push an item to the start of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
*/
native static int __push (long self, long item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void close () {
/*
Add an item to the head of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
*/
native static long __addStart (long self, long item);
public long addStart (long item) {
Expand All @@ -68,7 +68,7 @@ public long addStart (long item) {
/*
Add an item to the tail of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
*/
native static long __addEnd (long self, long item);
public long addEnd (long item) {
Expand Down Expand Up @@ -230,8 +230,7 @@ public void sort () {
duplicator, if any, on the item. If low_value is true, starts searching
from the start of the list, otherwise searches from the end. Use the item
comparator, if any, to find where to place the new node. Returns a handle
to the new node, or NULL if memory was exhausted. Resets the cursor to the
list head.
to the new node. Resets the cursor to the list head.
*/
native static long __insert (long self, long item, boolean lowValue);
public long insert (long item, boolean lowValue) {
Expand Down
11 changes: 5 additions & 6 deletions bindings/lua_ffi/czmq_ffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1688,13 +1688,13 @@ void *
zlist_item (zlist_t *self);

// Append an item to the end of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
int
zlist_append (zlist_t *self, void *item);

// Push an item to the start of the list, return 0 if OK or -1 if this
// failed for some reason (out of memory). Note that if a duplicator has
// failed for some reason (invalid input). Note that if a duplicator has
// been set, this method will also duplicate the item.
int
zlist_push (zlist_t *self, void *item);
Expand Down Expand Up @@ -1785,13 +1785,13 @@ zlistx_t *

// Add an item to the head of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
void *
zlistx_add_start (zlistx_t *self, void *item);

// Add an item to the tail of the list. Calls the item duplicator, if any,
// on the item. Resets cursor to list head. Returns an item handle on
// success, NULL if memory was exhausted.
// success.
void *
zlistx_add_end (zlistx_t *self, void *item);

Expand Down Expand Up @@ -1896,8 +1896,7 @@ void
// duplicator, if any, on the item. If low_value is true, starts searching
// from the start of the list, otherwise searches from the end. Use the item
// comparator, if any, to find where to place the new node. Returns a handle
// to the new node, or NULL if memory was exhausted. Resets the cursor to the
// list head.
// to the new node. Resets the cursor to the list head.
void *
zlistx_insert (zlistx_t *self, void *item, bool low_value);

Expand Down
11 changes: 5 additions & 6 deletions bindings/python/czmq/_czmq_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3740,15 +3740,15 @@ def item(self):
def append(self, item):
"""
Append an item to the end of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
"""
return lib.zlist_append(self._as_parameter_, item)

def push(self, item):
"""
Push an item to the start of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
"""
return lib.zlist_push(self._as_parameter_, item)
Expand Down Expand Up @@ -3974,15 +3974,15 @@ def add_start(self, item):
"""
Add an item to the head of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
"""
return c_void_p(lib.zlistx_add_start(self._as_parameter_, item))

def add_end(self, item):
"""
Add an item to the tail of the list. Calls the item duplicator, if any,
on the item. Resets cursor to list head. Returns an item handle on
success, NULL if memory was exhausted.
success.
"""
return c_void_p(lib.zlistx_add_end(self._as_parameter_, item))

Expand Down Expand Up @@ -4126,8 +4126,7 @@ def insert(self, item, low_value):
duplicator, if any, on the item. If low_value is true, starts searching
from the start of the list, otherwise searches from the end. Use the item
comparator, if any, to find where to place the new node. Returns a handle
to the new node, or NULL if memory was exhausted. Resets the cursor to the
list head.
to the new node. Resets the cursor to the list head.
"""
return c_void_p(lib.zlistx_insert(self._as_parameter_, item, low_value))

Expand Down
4 changes: 2 additions & 2 deletions bindings/python_cffi/czmq_cffi/Zlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def item(self):
def append(self, item):
"""
Append an item to the end of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
"""
return utils.lib.zlist_append(self._p, item._p)

def push(self, item):
"""
Push an item to the start of the list, return 0 if OK or -1 if this
failed for some reason (out of memory). Note that if a duplicator has
failed for some reason (invalid input). Note that if a duplicator has
been set, this method will also duplicate the item.
"""
return utils.lib.zlist_push(self._p, item._p)
Expand Down

0 comments on commit b588b95

Please sign in to comment.