nuttx/mm/iob/iob_peek_queue.c
Alin Jerpelea bcee9c391c mm: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00

81 lines
2.7 KiB
C

/****************************************************************************
* mm/iob/iob_peek_queue.c
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/mm/iob.h>
#include "iob.h"
#if CONFIG_IOB_NCHAINS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef NULL
# define NULL ((FAR void *)0)
#endif
/****************************************************************************
* 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 */