telldir.c (282560) | telldir.c (288029) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/lib/libc/gen/telldir.c 282560 2015-05-06 17:23:42Z jhb $"); | 34__FBSDID("$FreeBSD: head/lib/libc/gen/telldir.c 288029 2015-09-20 20:23:16Z rodrigc $"); |
35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/queue.h> 39#include <dirent.h> 40#include <pthread.h> 41#include <stdlib.h> 42#include <unistd.h> 43#include "un-namespace.h" 44 45#include "libc_private.h" 46#include "gen-private.h" 47#include "telldir.h" 48 49/* 50 * return a pointer into a directory 51 */ 52long | 35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/queue.h> 39#include <dirent.h> 40#include <pthread.h> 41#include <stdlib.h> 42#include <unistd.h> 43#include "un-namespace.h" 44 45#include "libc_private.h" 46#include "gen-private.h" 47#include "telldir.h" 48 49/* 50 * return a pointer into a directory 51 */ 52long |
53telldir(dirp) 54 DIR *dirp; | 53telldir(DIR *dirp) |
55{ 56 struct ddloc *lp; 57 long idx; 58 59 if (__isthreaded) 60 _pthread_mutex_lock(&dirp->dd_lock); 61 LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) { 62 if (lp->loc_seek == dirp->dd_seek && --- 18 unchanged lines hidden (view full) --- 81 return (idx); 82} 83 84/* 85 * seek to an entry in a directory. 86 * Only values returned by "telldir" should be passed to seekdir. 87 */ 88void | 54{ 55 struct ddloc *lp; 56 long idx; 57 58 if (__isthreaded) 59 _pthread_mutex_lock(&dirp->dd_lock); 60 LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) { 61 if (lp->loc_seek == dirp->dd_seek && --- 18 unchanged lines hidden (view full) --- 80 return (idx); 81} 82 83/* 84 * seek to an entry in a directory. 85 * Only values returned by "telldir" should be passed to seekdir. 86 */ 87void |
89_seekdir(dirp, loc) 90 DIR *dirp; 91 long loc; | 88_seekdir(DIR *dirp, long loc) |
92{ 93 struct ddloc *lp; 94 struct dirent *dp; 95 96 LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) { 97 if (lp->loc_index == loc) 98 break; 99 } --- 47 unchanged lines hidden (view full) --- 147 } 148 } 149} 150 151/* 152 * Reclaim memory for telldir cookies which weren't used. 153 */ 154void | 89{ 90 struct ddloc *lp; 91 struct dirent *dp; 92 93 LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) { 94 if (lp->loc_index == loc) 95 break; 96 } --- 47 unchanged lines hidden (view full) --- 144 } 145 } 146} 147 148/* 149 * Reclaim memory for telldir cookies which weren't used. 150 */ 151void |
155_reclaim_telldir(dirp) 156 DIR *dirp; | 152_reclaim_telldir(DIR *dirp) |
157{ 158 struct ddloc *lp; 159 struct ddloc *templp; 160 161 lp = LIST_FIRST(&dirp->dd_td->td_locq); 162 while (lp != NULL) { 163 templp = lp; 164 lp = LIST_NEXT(lp, loc_lqe); 165 free(templp); 166 } 167 LIST_INIT(&dirp->dd_td->td_locq); 168} | 153{ 154 struct ddloc *lp; 155 struct ddloc *templp; 156 157 lp = LIST_FIRST(&dirp->dd_td->td_locq); 158 while (lp != NULL) { 159 templp = lp; 160 lp = LIST_NEXT(lp, loc_lqe); 161 free(templp); 162 } 163 LIST_INIT(&dirp->dd_td->td_locq); 164} |