incubator-nuttx/mm/iob/iob_peek_queue.c

73 lines
2.4 KiB
C
Raw Normal View History

2014-06-25 05:46:10 +08:00
/****************************************************************************
* mm/iob/iob_peek_queue.c
2014-06-25 05:46:10 +08:00
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
2014-06-25 05:46:10 +08:00
*
* http://www.apache.org/licenses/LICENSE-2.0
2014-06-25 05:46:10 +08:00
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
2014-06-25 05:46:10 +08:00
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/mm/iob.h>
2014-06-25 05:46:10 +08:00
#include "iob.h"
#if CONFIG_IOB_NCHAINS > 0
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: iob_peek_queue
*
* Description:
* Return a reference to the I/O buffer chain at the head of a queue. This
* is similar to iob_remove_queue except that the I/O buffer chain is in
* place at the head of the queue. The I/O buffer chain may safely be
* modified by the caller but must be removed from the queue before it can
* be freed.
*
* Returned Value:
* Returns a reference to the I/O buffer chain at the head of the queue.
*
****************************************************************************/
FAR struct iob_s *iob_peek_queue(FAR struct iob_queue_s *iobq)
{
FAR struct iob_qentry_s *qentry;
FAR struct iob_s *iob = NULL;
/* Peek at the I/O buffer chain container at the head of the queue */
qentry = iobq->qh_head;
if (qentry)
{
/* Return the I/O buffer chain from the container */
iob = qentry->qe_head;
}
return iob;
}
#endif /* CONFIG_IOB_NCHAINS > 0 */