]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nodeinfo: drop static variable
authorEric Blake <eblake@redhat.com>
Fri, 11 May 2012 18:50:08 +0000 (12:50 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 14 May 2012 16:44:43 +0000 (10:44 -0600)
commit88f12a3665438cbd390a9190edbc5fa1eddb25ae
treedbf0935110db3752b45443232dee63f33b9f096b
parent5f89c86004c1c1f23b79fc2d8ee7dbc6f73f6200
nodeinfo: drop static variable

We were wasting time to malloc a copy of a constant string, then
copy it into static storage, for every call to nodeGetInfo.  At
least we were lucky that it was a constant source, and thus not
subject to even worse issues with one thread clobbering the static
storage while another was using it.  This gets rid of the waste,
by passing the string through the stack instead, as well as renaming
internal functions to better match our conventions.

* src/nodeinfo.c (sysfs_path): Delete.
(get_cpu_value, count_thread_siblings, parse_socket): Add
parameter, and rename...
(virNodeGetCpuValue, virNodeCountThreadSiblings)
(virNodeParseSocket): ... into a common namespace.
(cpu_online, parse_core): Inline into callers.
(linuxNodeInfoCPUPopulate): Update caller.
(nodeGetInfo): Drop a useless malloc.
src/nodeinfo.c