1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

viralloc: use consistent naming

Commit 0df3e89 only touched the header, but the .c file had the
same shadowing potential.

* src/util/viralloc.c (virDeleteElementsN): s/remove/toremove/ to
match the header.
This commit is contained in:
Eric Blake 2013-03-07 07:53:42 -07:00
parent 374631d016
commit 2e6322a7a5

View File

@ -1,7 +1,7 @@
/* /*
* viralloc.c: safer memory allocation * viralloc.c: safer memory allocation
* *
* Copyright (C) 2010-2012 Red Hat, Inc. * Copyright (C) 2010-2013 Red Hat, Inc.
* Copyright (C) 2008 Daniel P. Berrange * Copyright (C) 2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -328,7 +328,7 @@ virInsertElementsN(void *ptrptr, size_t size, size_t at,
* @size: the size of one element in bytes * @size: the size of one element in bytes
* @at: index within array where new elements should be deleted * @at: index within array where new elements should be deleted
* @countptr: variable tracking number of elements currently allocated * @countptr: variable tracking number of elements currently allocated
* @remove: number of elements to remove * @toremove: number of elements to remove
* @inPlace: false if we should shrink the allocated memory when done, * @inPlace: false if we should shrink the allocated memory when done,
* true if we should assume someone else will do that. * true if we should assume someone else will do that.
* *
@ -341,12 +341,12 @@ virInsertElementsN(void *ptrptr, size_t size, size_t at,
*/ */
int int
virDeleteElementsN(void *ptrptr, size_t size, size_t at, virDeleteElementsN(void *ptrptr, size_t size, size_t at,
size_t *countptr, size_t remove, size_t *countptr, size_t toremove,
bool inPlace) bool inPlace)
{ {
if (at + remove > *countptr) { if (at + toremove > *countptr) {
VIR_WARN("out of bounds index - count %zu at %zu remove %zu", VIR_WARN("out of bounds index - count %zu at %zu toremove %zu",
*countptr, at, remove); *countptr, at, toremove);
return -1; return -1;
} }
@ -355,12 +355,12 @@ virDeleteElementsN(void *ptrptr, size_t size, size_t at,
* already been cleared. * already been cleared.
*/ */
memmove(*(char**)ptrptr + (size * at), memmove(*(char**)ptrptr + (size * at),
*(char**)ptrptr + (size * (at + remove)), *(char**)ptrptr + (size * (at + toremove)),
size * (*countptr - remove - at)); size * (*countptr - toremove - at));
if (inPlace) if (inPlace)
*countptr -= remove; *countptr -= toremove;
else else
virShrinkN(ptrptr, size, countptr, remove); virShrinkN(ptrptr, size, countptr, toremove);
return 0; return 0;
} }